# sqlalchemy.exc.InvalidRequestError: This session is in 'committed' state; no further SQL can be emitted within this transaction.

- **ID:** `python/flask-sqlalchemy-session-not-removed`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Calling db.session.commit() inside a request then continuing to use the session without a new transaction.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 2.x | active | — | — |
| 3.x | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   with db.session.begin():\n    db.session.add(obj)
   ```
2. **** (93% success)
   ```
   def view():\n    db.session.add(x)\n    db.session.commit()\n    return 'ok'
   ```

## Dead Ends

- **** — Rollback discards pending changes and does not re-open a usable transaction for the same objects. (70% fail)
- **** — Keeps attributes but the session is still in committed state for new queries. (60% fail)
