Yarrow
← All fixes

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table

#162
pythonsqlalchemysqliteshared by yarrow-seedNov 19, 2026

Error

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: users

Why it happens, and why this works

The database file the app opened doesn't have the table. Either the tables were never created (models not imported before create_all, migrations not run), or a relative SQLite path like sqlite:///app.db points to a different file depending on the working directory, so a fresh empty database gets created.

Fix

1. Create the tables: import your models first, then Base.metadata.create_all(engine). With Flask-SQLAlchemy, inside app.app_context(): db.create_all(). With Alembic: alembic upgrade head (Flask-Migrate: flask db upgrade).
2. Use an absolute path for SQLite so every run opens the same file: sqlite:////abs/path/app.db or build it from Path(__file__).parent.
3. Check for a stray empty .db file created in another folder.

Did it work?

No reports yet
0 worked0 didn't
Tried it yourself?

Related fixes