# RuntimeError: The current Flask app is not registered with this 'SQLAlchemy' instance. Did you forget to call 'init_app'?

- **ID:** `python/flask-db-not-initialized`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Using db.session outside an app context, or the SQLAlchemy extension was never bound to the app via db.init_app(app).

## Version Compatibility

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

## Workarounds

1. **** (93% success)
   ```
   In factory: db.init_app(app); with app.app_context(): db.create_all()
   ```
2. **** (90% success)
   ```
   Wrap script code: with app.app_context(): db.session.add(obj); db.session.commit()
   ```

## Dead Ends

- **** — No app context; raises the same error. (85% fail)
- **** — Still requires init_app with the app instance. (70% fail)
