generated from coulomb/repo-seed
11 lines
445 B
Python
11 lines
445 B
Python
from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine
|
|
from .models import Base
|
|
|
|
DATABASE_URL = "postgresql+asyncpg://user:pass@localhost/dvd_db" # From env
|
|
|
|
engine = create_async_engine(DATABASE_URL, echo=True)
|
|
async_session = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
|
|
|
|
async def init_db():
|
|
async with engine.begin() as conn:
|
|
await conn.run_sync(Base.metadata.create_all) |