Добавлено сохранение заказов в postgres
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user