from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession, async_sessionmaker import os # Same shape as DealGod's db.py — async SQLAlchemy over asyncpg. RecordGod owns its OWN db. DATABASE_URL = os.getenv("DATABASE_URL", "postgresql+asyncpg://localhost/recordgod") engine = create_async_engine( DATABASE_URL, pool_size=5, max_overflow=5, pool_timeout=30, pool_recycle=900, pool_pre_ping=True) SessionLocal = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False) async def get_db(): async with SessionLocal() as session: yield session # Read-only enrichment mirror — the full Discogs dump (same local Postgres, different db). # We DON'T copy the catalog into RecordGod; intake joins it on release_id at write time. MIRROR_URL = os.getenv("DISCOGS_MIRROR_URL", "postgresql+asyncpg://localhost/discogs_full") mirror_engine = create_async_engine(MIRROR_URL, pool_size=2, max_overflow=2, pool_pre_ping=True) MirrorSession = async_sessionmaker(mirror_engine, class_=AsyncSession, expire_on_commit=False)