# RuntimeError: A 'SQLAlchemy' instance has already been registered on this Flask app. Import and use that instance instead.

- **ID:** `python/flask-sqlalchemy-multiple-instances`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Two db = SQLAlchemy() objects created in different modules and both init_app(app) called.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   Create db once in extensions.py: from flask_sqlalchemy import SQLAlchemy; db = SQLAlchemy()  # import everywhere else
   ```
2. **** (92% success)
   ```
   In factory: from .extensions import db; db.init_app(app)  # only once
   ```

## Dead Ends

- **** — Raises again; second instance is unusable. (90% fail)
- **** — Old versions silently misbehave; data bugs appear later. (70% fail)
