chore: setup project and copy lab2 code

This commit is contained in:
2026-10-28 23:21:31 +03:00
parent 0ab3a341aa
commit 7fd38cf2e2
21 changed files with 1344 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
import os
from sqlalchemy.ext.asyncio import (
AsyncSession,
async_sessionmaker,
create_async_engine,
)
DATABASE_URL = os.getenv(
"DATABASE_URL",
"postgresql+asyncpg://messenger:strongpassword@localhost:5432/messenger",
)
engine = create_async_engine(
DATABASE_URL,
pool_size=10,
max_overflow=20,
pool_timeout=5,
pool_recycle=1800,
pool_pre_ping=True,
connect_args={"timeout": 5, "command_timeout": 10},
)
async_session = async_sessionmaker(
engine, class_=AsyncSession, expire_on_commit=False
)
async def get_db() -> AsyncSession:
async with async_session() as session:
yield session