Lab 8 - More Python database accessing


Exercise 1

Read the Movie table and write it to a file in the following format:

id name year rating runtime genre earnings_rank


Exercise 2

Read the Person table and write it to file in the following format:

id name dob pob

But change the format of dob from yyyy-mm-dd to mm/dd/yyyy.


Exercise 3

Assume that our task is to draw a chart that shows the number of films in various runtime ranges in a database. We have a database as the source of information. The table we will work wth has the following schema:

Movie ( id , name , year , rating , runtime , genre , earnings_rank )

Our task is to count the number of films in the following runtime ranges: 60-69 min, 70-79 min, 80-89 min, 90-99 min, 100-109 min, 110-119 min, 120-129 min, 130-139 min, 140-149 min, .. , 230 - 239 min.

Hint: Execute one query to get the results for all the runtimes first. Then, do a post-processing of these results with Python code. You will need to keep a list of counters, one for each runtime range. Then, for every record in the result, you will need to decide which runtime counter to update


CS105