from sqlalchemy.ext.asyncio import create_async_engine, async_sessionmaker
from sqlalchemy.orm import DeclarativeBase

# Using SQLite for easy local testing without Docker. 
# For Production, switch to PostgreSQL as per ADR-007.
DATABASE_URL = "sqlite+aiosqlite:///./dvd_local.db"
# DATABASE_URL = "postgresql+asyncpg://user:password@localhost/dvd_db"

engine = create_async_engine(DATABASE_URL, echo=True)
AsyncSessionLocal = async_sessionmaker(engine, expire_on_commit=False)

class Base(DeclarativeBase):
    pass

async def get_db():
    async with AsyncSessionLocal() as session:
        yield session