flask/sqlalchemy - OperationalError: (sqlite3.OperationalError) no such table
You're supposed to initialize/create the tables first. Please read the Creating the Database article in the official Flask documentation:
Such systems need a schema that tells them how to store that information. So before starting the server for the first time it’s important to create that schema.
Here's Flask's example of using a schema SQL script to create the database, tables, etc:
sqlite3 /tmp/flaskr.db < schema.sql
The recommended way is to use db.create_all()
within your app. For example, see: https://github.com/lily-mayfield/staticfuzz/blob/d2e54186f5639a06a5a796f0499a984ca8919ed7/staticfuzz.py#L403
What helped me in the the same scenario where the db file wasn't created correctly is to run from terminal:
In terminal type command:
flask init-db
Then and then run the app again with command:
flask run
This updated the example db file correctly.