Question
Using the Python code below write 3 automated tests show the data table was created and exists import feedparser import webbrowser import mysql.connector # sudo
Using the Python code below write 3 automated tests show the data table was created and exists
import feedparser
import webbrowser
import mysql.connector
# sudo apt-get install python3-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") #test
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started