How to create (in Flask using flask-SA etc.) an SQLite DB file with metadata.create_all(..)
-
21-12-2019 - |
Question
I have a flask application spread across modules with blueprints. Each module/blueprint has its own models.py file where models are defined.
When the application runs, I would like SQLAlchemy to create the SQLite file at the location set with SQLALCHEMY_DATABASE_URI
configuration.
With a regular Python application without any extraction layers above SA using base.metadata.create_all(..)
How can I do this with Flask and SQLAlchemy extension?
Solution
I suspect you have somewhere :
db = SQLAlchemy(app)
so all you have to do is
db.create_all()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow