10 lines
407 B
Python
10 lines
407 B
Python
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
|
|
|
|
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 |