Question: Solve this compile errors for the following python code compile error: Traceback (most recent call last): File main.py, line 3, in import mysql.connector ModuleNotFoundError: No

Solve this compile errors for the following python code

compile error: Traceback (most recent call last): File "main.py", line 3, in import mysql.connector ModuleNotFoundError: No module named 'mysql'

import feedparser

import webbrowser

import mysql.connector

mydb = mysql.connector(

host="localhost",

user="yourusername",

passwd="yourpassword",

database="mydatabase"

)

mycursor= mydb.cursor()

feed = feedparser.parse("https://stackoverflow.com/jobs/feed")

feed_entries= feed.entries

# feed_title = feed['feed']['title'] # NOT VALID

feed_entries = feed.entries

for entry in feed.entries:

job_title = entry.title

job_link = entry.link

job_published_at = entry.published # Unicode string

job_published_at_parsed = entry.published_parsed # Time object

# job_author = entry.author DOES NOT EXIST

content = entry.summary

# job_tags = entry.tags DOES NOT EXIST

sql="INSERT INTO entries (job_title,job_link,job_published_at,content) VALUES (%s,%s,%s,%s)"

val=(job_title,job_link,job_published_at,content)

mycursor.execute(sql,val)

mydb.commit()

print(mycursor.rowcount, "Record Inserted")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!