# 此会话处于“关闭”状态。无法在此事务中发出更多 SQL。

- **ID:** `python/sqlalchemy-exc-invalid-request-query-on-closed-session`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

尝试在已明确关闭或事务已结束的会话上执行查询。

## 版本兼容性

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

## 解决方案

1. **Create new session** (95% 成功率)
   ```
   Create a new session instance: new_session = Session(); new_session.query(User).all()
   ```
2. **Check session is_active** (85% 成功率)
   ```
   Ensure the session is not closed prematurely by checking session.is_active before queries.
   ```

## 无效尝试

- **Trying to reopen session** —  (80% 失败率)
- **Using non-existent method** —  (90% 失败率)
