This project was developed for the "Databases" course and aims to design a model of a database and implement it. Afterwards we should also develop a simple Python application for the database. This project is subdivided into two parts.
Authors:
- Magda Costa
- Rafael Pacheco
- Sofia Machado
- Python 3
- Pip 3 Package Manager
- sqlite3
- Flask
- Jinja Templates
- Python 3
python3 --version- Pip3:
pip3 --version- Flask:
flask --version- sqlite3:
sqlite3 --version- Python 3 and Pip 3
sudo apt-get install python3 python3-pip- Flask:
pip3 install --user Flask- sqlite3:
sudo apt install sqlite3Note: When you install Flask, Jinja is automatically installed.
In the first part of the project, we were expected to design a database model for a universe of our choice supported with real data, considering:
- the description of the universe in question and a corresponding UML class diagram;
- mapping the UML class model into a relational model;
Worked develop: To accomplish this part, we started by doing intensive research on sites like Kaggle to find data that would allow us to carry out the project within the constraints defined in the project statement. To make this possible, we selected a dataset with the 'Disney' theme and completed it so that we could use it.
This part of the project is intended to implement the database model proposed in part 1 in an SQLite database populated with the data and the development of a simple python app of the interface for the database.
Worked develop: We start by creating the SQLite database and then we create the application that allows us to search by character, by the director of the film... It also allows us to see the relationships between each table created in the database model and do different types of searches through data.
In this repository we have two folders correspondent to the two parts:
🔵 Part 1:
- assignment_part_1.pdf ➡️ Description of what is requested for part 1 of the project;
- project_part_1.pdf ➡️ Resolution of part 1;
- Excels ➡️ Folder with the excels extracted from Kaggle;
- CSVs ➡️ Converted excels to CSVs;
🔵 Part 2:
- assignment_part_2.pdf ➡️ Description of what is requested for part 2 of the project;
- project_part_1.pdf ➡️ Resolution of part 1;
- project_part_2.pdf ➡️ Resolution of part 2;
- Disney.db ➡️ The database created in SQLiteStudio
- App:
- static ➡️ Folder with css and an image that was used
- templates ➡️ HTML files
Edit the db.py file regarding your DB configuration, modifying the DB_FILE parameters that indicate the database file. The SQLite file for DB must reside in the same folder as the app.py file.
Test access by running:
python3 test_db_connection.py TABLE_NAMEIf the DB access configuration is correct, the contents of the TABLE_NAME table should be listed, for example. the DB Disney Genre table:
$ python3 test_db_connection.py Genre
connected <sqlite3.Connection object at 0x7f7a6d146120>
10 results ...
[('IdGenre', 1), ('Name', 'Comedy'), ('Description', 'Intended to be humorous or amusing by inducing laughter')]
[('IdGenre', 2), ('Name', 'Animation'), ('Description', 'A motion picture that is made from a series of drawings, computer graphics, or photographs of inanimate objects (such as puppets) and that simulates movement by slight progressive changes in each frame.')]
[('IdGenre', 3), ('Name', 'Action'), ('Description', 'Action film is\xa0a film genre in which the protagonist is thrust into a series of events that typically involve violence and physical feats.')]
[('IdGenre', 4), ('Name', 'Adventure'), ('Description', 'Characters often exploring places they have not been before or doing things they have not done before.')]
[('IdGenre', 5), ('Name', 'Drama'), ('Description', 'Involves conflicts, emotions, and the portrayal of human experiences through dialogue and action.')]
[('IdGenre', 6), ('Name', 'Musical'), ('Description', 'A film genre in which songs by the characters are interwoven into the narrative, sometimes accompanied by dancing')]
[('IdGenre', 7), ('Name', 'Romance'), ('Description', 'Focus on the relationship and romantic love between two people')]
[('IdGenre', 8), ('Name', 'Fantasy'), ('Description', 'Films that belong to the fantasy genre with fantastic themes, usually magic, supernatural events, mythology, folklore, or exotic fantasy worlds.')]
[('IdGenre', 9), ('Name', 'Mistery'), ('Description', 'A genre of film that revolves around the solution of a problem or a crime')]
[('IdGenre', 10), ('Name', 'Science Fiction'), ('Description', 'Uses speculative, fictional science-based depictions of phenomena that are not fully accepted by mainstream science, such as extraterrestrial lifeforms, spacecraft, robots, cyborgs, mutants...')]Access the terminal and make sure it is in the 'APP' directory to access it. Run the command:
python3 server.pyThe following code will be displayed:
$ python3 server.py
connected <sqlite3.Connection object at 0x7fbadc57de40>
2025-01-22 19:30:37 - INFO - Connected to database
* Serving Flask app 'app'
* Debug mode: off
2025-01-22 19:30:37 - INFO - WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:9000
* Running on http://172.23.245.160:9000Then open in your browser http://127.0.0.1:9000 or http://172.23.245.160:9000
This course is part of the first semester of the second year of the Bachelor's Degree in Artificial Intelligence and Data Science at FCUP and FEUP in the academic year 2023/2024. You can find more information about this course at the following link: