19 lines
485 B
Python
Raw Normal View History

2025-03-29 17:42:12 +03:00
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
from sqlalchemy.orm import sessionmaker
from loader import SECRETS
engine = create_async_engine(SECRETS.postgres_url, max_overflow=-1)
async_session = sessionmaker(engine, expire_on_commit=False, class_=AsyncSession)
async def get_session() -> AsyncSession:
"""Получение сессии БД
Returns:
AsyncSession
"""
async with async_session() as session:
return session