Example flask app based on framework of Peter Mooring
Initial notes:
bootstrap_flask is needed to avoid error jinja2.exceptions.TemplateNotFound: bootstrap/nav.html
Following modules must be installed:
flask
flask_wtf
flask_bootstrap4
sqlalchemy
bootstrap_flask
wtforms_sqlalchemy
After running the initial alembic commands you should see the following output
(venv) pi@rpi3Bimmcff ~/mystuff/flask/gvflask/project$ alembic revision -m "First revision"
Generating /home/pi/mystuff/flask/gvflask/project/alembic/versions/aa89aa4df9a9_first_revision.py ... done
(venv) pi@rpi3Bimmcff ~/mystuff/flask/gvflask/project$ alembic upgrade head
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running upgrade -> aa89aa4df9a9, First revision
This will also create the intial database "app.db" for this example app.
Now only the alembic table is created, not yet the tables for the application itself. To do this, the following must be run:
(venv) pi@rpi3Bimmcff ~/mystuff/flask/gvflask/project$ alembic revision --autogenerate -m "Create the database"
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.autogenerate.compare] Detected added table 'city'
INFO [alembic.autogenerate.compare] Detected added table 'hobby'
INFO [alembic.autogenerate.compare] Detected added table 'friend'
INFO [alembic.autogenerate.compare] Detected added table 'friend_mtm_hobby'
Generating /home/pi/mystuff/flask/gvflask/project/alembic/versions/65d5a8dd0649_create_the_database.py ... done
(venv) pi@rpi3Bimmcff ~/mystuff/flask/gvflask/project$ alembic upgrade head
INFO [alembic.runtime.migration] Context impl SQLiteImpl.
INFO [alembic.runtime.migration] Will assume non-transactional DDL.
INFO [alembic.runtime.migration] Running upgrade aa89aa4df9a9 -> 65d5a8dd0649, Create the database
Only now the extra tables are created and can be used.