Spaces:
Runtime error
Runtime error
Download src/app/database.py from welcometoFightclub/datacollection_server: direct link, hf CLI and curl.
- Browser
- Download file 491 Bytes
-
https://huggingface.co/spaces/welcometoFightclub/datacollection_server/resolve/main/src/app/database.py
- Command line
-
hf download hf://spaces/welcometoFightclub/datacollection_server/src/app/database.py
-
curl -L -o database.py https://huggingface.co/spaces/welcometoFightclub/datacollection_server/resolve/main/src/app/database.py
491 Bytes
| from collections.abc import AsyncIterator | |
| from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine | |
| from app.core.config import get_settings | |
| settings = get_settings() | |
| settings.ensure_data_directory() | |
| engine = create_async_engine(settings.database_url, future=True) | |
| SessionFactory = async_sessionmaker(engine, expire_on_commit=False) | |
| async def get_session() -> AsyncIterator[AsyncSession]: | |
| async with SessionFactory() as session: | |
| yield session | |