Spaces:
Sleeping
Sleeping
Download backend/app/database.py from avborg/adventure-log: direct link, hf CLI and curl.
- Browser
- Download file 453 Bytes
-
https://huggingface.co/spaces/avborg/adventure-log/resolve/main/backend/app/database.py
- Command line
-
hf download hf://spaces/avborg/adventure-log/backend/app/database.py
-
curl -L -o database.py https://huggingface.co/spaces/avborg/adventure-log/resolve/main/backend/app/database.py
453 Bytes
| from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine, async_sessionmaker | |
| from sqlalchemy.orm import DeclarativeBase | |
| from app.core.config import settings | |
| engine = create_async_engine(settings.database_url, echo=False) | |
| AsyncSessionLocal = async_sessionmaker(engine, expire_on_commit=False) | |
| class Base(DeclarativeBase): | |
| pass | |
| async def get_db() -> AsyncSession: | |
| async with AsyncSessionLocal() as session: | |
| yield session | |