Добавлено сохранение заказов в postgres

This commit is contained in:
Раис Юсупалиев
2026-04-18 00:33:45 +03:00
parent 2b201a08be
commit bddac60965
38 changed files with 971 additions and 17 deletions
View File
+16
View File
@@ -0,0 +1,16 @@
"""PostgreSQL async engine and session factory management."""
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, async_sessionmaker
from sqlalchemy.ext.asyncio import create_async_engine
from app.config import PostgresConfig
def create_postgres_engine(config: PostgresConfig) -> AsyncEngine:
return create_async_engine(config.dsn, pool_pre_ping=True)
def create_postgres_session_factory(
engine: AsyncEngine,
) -> async_sessionmaker[AsyncSession]:
return async_sessionmaker(engine, expire_on_commit=False)