# ImportError: cannot import name 'db' from partially initialized module 'app' (most likely due to a circular import)

- **ID:** `python/flask-circular-import`
- **Domain:** python
- **Category:** module_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Two modules import each other at module load time, typically models importing app and app importing models.

## Version Compatibility

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

## Workarounds

1. **** (93% success)
   ```
   def create_app():
    app = Flask(__name__)
    db.init_app(app)
    return app
   ```
2. **** (91% success)
   ```
   # extensions.py
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
   ```

## Dead Ends

- **** — Only changes which side fails first; cycle remains. (85% fail)
- **** — Leaves db undefined and crashes later. (90% fail)
