Question: Python Question Question: Video Store [2 points] Recall the movie database example given in class. In this question, you are to complete two functions in

Python Question

Python Question Question: Video Store [2 points] Recall the movie database example

Question: Video Store [2 points] Recall the movie database example given in class. In this question, you are to complete two functions in the following cell using the table movies from videostore.db For the function allMovies() ,return a list of all movie records where each record is in the form of tuple. For example, if table movies of videostore.db contains only two records, say: (101, 'Casablanca', "drama romance', 'PG), (102, 'Back to the Future', 'comedy adventure', 'PG), then the function should return the list: (101, Casablanca'drama romance' PG, (102, Back to the uturecomedy adventur e PG The function addMovie (movieid, title, genre, rating) takes four inputs to add a new movie record to the database. For simplicity, you may assume that all inputs to addMovies(.. are appropriate. In Jimport sqlite3 def allMovies ( dbsglite3.connect( 'videostore.db) #construct the appropriate SQL query to get all movie records #from the table movies, and return the list containing all #movie records where each movie record is in the form of a tuple db.close() def addMovie (movieid, title, genre, rating): dbsglite3.connect( 'videostore.db) #construct the appropriate SQL query to insert a new movie data #10 the table moves db.close() In I J data-allMovies) addMovie (121, 'B in China', documentary, 'PG) # to check if the new movie has added to the database data.append( (121, Born in China', "documentaryPG)) assert set (data)set (allMovies()) In [ ]: # Hidden test for video store

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!