- Install MySQL on your local machine.
- https://dev.mysql.com/downloads/mysql/
- If you prefer to use a MySQL client, see e.g., MySQL Workbench.
- Create a MySQL database called
dat310
. - Create a table called
movies
with the following structure:imdb_id VARCHAR(20)
we'll use the IMDB movie IDs as a unique identifier and PRIMARY KEYtitle VARCHAR(40)
year INT
rating DOUBLE
synopsis TEXT
- Add some movies to the table.
- You may create the table and add data using the movies.sql script.
- Install MySQL Connector/Python
- on the command line:
conda install mysql-connector-python
- on the command line:
Update Exercise 4 from the last lecture such that movies are loaded from the MySQL database.
Specifically,
- Remove the
MOVIES
const; this data will need to be loaded from the database. - Make a connection to the database (make sure the DB and the movies table have been created).
- Make a
SELECT
query that returns all movies from the table. - Notice that are not storing the IMDB URLs in the database. You'll need to generate the links to the IMDB movie pages from the
imdb_id
field. Do that in themovies.html
template file (i.e., not inapp.py
).
The output should look exactly as before:
Generate a separate "details" page for each movie.
- Remove the links to the IMDB profile page from the movie listing. Instead, make the title of the movie a link to
/movie/<movie_id>
, wheremovie_id
refers to theid
field in themovies
table. - Make a
layout.html
file that contain a common header and footer. The movie listing and movie details pages should extendlayout.html
.