Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions

Question

Demonstrate three aspects of assessing group performance?

Answered: 1 week ago