# sqlalchemy.exc.MissingGreenlet: greenlet_spawn has not been called; can't call await_only() here.

- **ID:** `python/fastapi-sqlalchemy-async-session-not-bound`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Lazy-loading a relationship on an AsyncSession outside an awaited greenlet context, e.g. in template rendering or sync code.

## Version Compatibility

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

## Workarounds

1. **** (94% success)
   ```
   from sqlalchemy.orm import selectinload
result = await session.execute(select(User).options(selectinload(User.posts)))
   ```
2. **** (88% success)
   ```
   await session.refresh(user, ['posts'])
   ```

## Dead Ends

- **** — Dynamic still requires I/O; the greenlet error persists. (80% fail)
- **** — Blocks the event loop and breaks FastAPI async handling. (85% fail)
