# sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) 没有这样的列: users.age

- **ID:** `python/sqlalchemy-no-such-column`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

ORM 模型定义了数据库中不存在的列，或表结构已过时。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **Use Alembic migrations to add the column** (95% 成功率)
   ```
   alembic revision --autogenerate -m "add age column"
alembic upgrade head
   ```
2. **Drop and recreate the table if in development** (85% 成功率)
   ```
   Base.metadata.drop_all(engine)
Base.metadata.create_all(engine)
   ```

## 无效尝试

- **Adding the column manually via raw SQL without updating the model** — The model may still reference the old schema if not refreshed. (65% 失败率)
- **Ignoring the error and assuming it's transient** — The error will persist until the schema is updated. (100% 失败率)
