Provides a quick way to setup sqlite database and flask. Uses jinja macros to render html. The project is meant to prioritise reusability and ease of adaptation to new data.
- Python
- Flask
- Sqlite3
python3 server.py
It is advised to use a Linux or MacOS machine for bash scripts.
Running import_tables.sh
will read the csv files at Tables/
and create import_test.db
file at project root directory.
./import_tables.sh
In the case that some columns of your data need to be removed:
- Place the original csv files at
Tables/full_backup/
directory. - Modify
drop_unnecessary.sql
file by addingDROP
statements for the columns to be removed. - Run
import_bulk.sh
script to populate the Tables directory with the distilled csv files.
- Replace example csv files in
Tables/
with your own csv files.
- Check Database Creation section to generate Sqlite database.
- Modify
models.py
to have successful object-table correspondence. - Modify
services/service.py
andviews.py
by adding class definitions for each table. - Modify
server.py
by using theset_urls()
function for each table. - Modify
templates/layout.html
to provide links to your table pages from the home page.
Sqlite3 is used as database.
SQL query generators reside in service.py which can be inherited by any table service class. Add, Update, Delete and Get methods of the parent class Service can be inherited by each table. They use objects in models to get information about columns.
Tables' columns are stored in models.py as reference. It is used by services to generate queries.
Url endpoints are declared in server.py. It is responsible to run the server. View functions are assigned to urls.
View functions are declared in views.py. It is responsible for connecting services with appropriate url's and template files which create html.
Jinja templates are in templates/ directory. Jinja macro list_macro.html is responsible of serving appropriate html file depending on the context and data.
CSV files are stored in Tables/ to have common source of data at database creation.