chore: migrate lab 2 implementation

This commit is contained in:
2026-10-23 16:17:29 +03:00
parent 0ab3a341aa
commit 3f7c306f4f
50 changed files with 1642 additions and 9 deletions
+23
View File
@@ -0,0 +1,23 @@
from __future__ import annotations
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, async_sessionmaker, create_async_engine
from sqlalchemy.orm import DeclarativeBase
class Base(DeclarativeBase):
pass
def create_engine(url: str) -> AsyncEngine:
return create_async_engine(
url,
pool_size=5,
max_overflow=5,
pool_timeout=5,
pool_pre_ping=True,
connect_args={'server_settings': {'statement_timeout': '5000'}},
)
def create_session_factory(engine: AsyncEngine) -> async_sessionmaker[AsyncSession]:
return async_sessionmaker(engine, expire_on_commit=False)