- FastAPI twin of DealGod (async SQLAlchemy/asyncpg). wowplatter/v1: ping, inventory/lookup, inventory/intake (enriches from discogs_full by release_id). - schema v2: unified inventory (vinyl+general), slim crate, sales/sale_items. Discogs catalog NOT copied — joined from discogs_full at read time. - migrate.py: 34,543 shop rows moved (vs ~3.2M in the WowPlatter clone). - Smoke test green; plan/readme carry the architecture + UI boundary. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
23 lines
1.0 KiB
Python
23 lines
1.0 KiB
Python
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)
|