mirror of
https://github.com/ZTatman/myst.git
synced 2026-11-21 12:27:59 +00:00
11 lines
328 B
Python
11 lines
328 B
Python
from collections.abc import AsyncGenerator
|
|
|
|
from fastapi import Request
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
|
|
async def get_db(request: Request) -> AsyncGenerator[AsyncSession]:
|
|
"""Yield a request-scoped async database session."""
|
|
|
|
async with request.app.state.db_session() as session:
|
|
yield session
|