Initial commit with 2026 World Cup Quant Platform core modules and CI/CD
This commit is contained in:
26
platform/backend/app/db/base.py
Normal file
26
platform/backend/app/db/base.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
|
||||
from sqlalchemy.orm import DeclarativeBase
|
||||
import os
|
||||
|
||||
|
||||
class Base(DeclarativeBase):
|
||||
"""Project ORM base model."""
|
||||
|
||||
|
||||
DATABASE_URL = os.getenv('DATABASE_URL', 'postgresql+asyncpg://fifa_user:change_me@fifa2026-postgres:5432/fifa2026')
|
||||
|
||||
|
||||
def get_engine(database_url: str = DATABASE_URL):
|
||||
"""Create asynchronous SQLAlchemy engine for production use."""
|
||||
|
||||
return create_async_engine(database_url, echo=False, pool_pre_ping=True)
|
||||
|
||||
|
||||
def get_session_factory(database_url: str = DATABASE_URL):
|
||||
"""Create session factory for async query operations."""
|
||||
|
||||
engine = get_engine(database_url)
|
||||
return async_sessionmaker(bind=engine, class_=AsyncSession, expire_on_commit=False)
|
||||
|
||||
|
||||
SessionFactory = get_session_factory()
|
||||
Reference in New Issue
Block a user