9 lines
406 B
Python
9 lines
406 B
Python
from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker, AsyncSession
|
|
from app.core.config import settings
|
|
|
|
engine = create_async_engine(settings.POSTGRES_DSN, echo=False, future=True)
|
|
AsyncSessionLocal = async_sessionmaker(engine, expire_on_commit=False, class_=AsyncSession)
|
|
|
|
async def get_session() -> AsyncSession:
|
|
async with AsyncSessionLocal() as session:
|
|
yield session |