Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Presentation Aids Practicing Your Speech?

Answered: 1 week ago