13488f7b21
- SQLAlchemy async models for sources, jobs, schedules, executions, backups, settings - Alembic migration configuration
17 lines
520 B
Python
17 lines
520 B
Python
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession, async_sessionmaker
|
|
from sqlalchemy.orm import declarative_base
|
|
|
|
DATABASE_URL = "sqlite+aiosqlite:///./backup_tool.db"
|
|
|
|
engine = create_async_engine(DATABASE_URL, echo=True)
|
|
AsyncSessionLocal = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False)
|
|
|
|
Base = declarative_base()
|
|
|
|
async def get_db():
|
|
async with AsyncSessionLocal() as session:
|
|
try:
|
|
yield session
|
|
finally:
|
|
await session.close()
|