lab2
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
2026-10-02 16:44:12 +03:00
parent 65003b6119
commit e167118875
39 changed files with 1810 additions and 44 deletions
+34
View File
@@ -0,0 +1,34 @@
from collections.abc import AsyncGenerator
from sqlalchemy.ext.asyncio import (
AsyncSession,
async_sessionmaker,
create_async_engine,
)
from src.core.config import settings
engine = create_async_engine(
settings.database_url,
echo=False,
pool_size=10,
max_overflow=20,
pool_pre_ping=True,
pool_recycle=1800,
)
async_session_factory = async_sessionmaker(
engine,
class_=AsyncSession,
expire_on_commit=False,
autoflush=False,
)
async def get_db() -> AsyncGenerator[AsyncSession, None]:
async with async_session_factory() as session:
try:
yield session
except Exception:
await session.rollback()
raise