python
runtime_error
ai_generated
true
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such column: users.age
ID: python/sqlalchemy-no-such-column
80%Fix Rate
84%Confidence
0Evidence
2025-01-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
The ORM model defines a column that does not exist in the database table, or the table schema is outdated.
generic中文
ORM 模型定义了数据库中不存在的列,或表结构已过时。
Workarounds
-
95% success Use Alembic migrations to add the column
alembic revision --autogenerate -m "add age column" alembic upgrade head
-
85% success Drop and recreate the table if in development
Base.metadata.drop_all(engine) Base.metadata.create_all(engine)
Dead Ends
Common approaches that don't work:
-
Adding the column manually via raw SQL without updating the model
65% fail
The model may still reference the old schema if not refreshed.
-
Ignoring the error and assuming it's transient
100% fail
The error will persist until the schema is updated.