Spaces:
Runtime error
Runtime error
Download services/api/app/db.py from Oheha/cybully-api: direct link, hf CLI and curl.
- Browser
- Download file 581 Bytes
-
https://huggingface.co/spaces/Oheha/cybully-api/resolve/main/services/api/app/db.py
- Command line
-
hf download hf://spaces/Oheha/cybully-api/services/api/app/db.py
-
curl -L -o db.py https://huggingface.co/spaces/Oheha/cybully-api/resolve/main/services/api/app/db.py
581 Bytes
| from __future__ import annotations | |
| from collections.abc import AsyncIterator | |
| from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine | |
| from app.core.config import get_settings | |
| from app.core.database_url import async_database_url | |
| settings = get_settings() | |
| engine = create_async_engine(async_database_url(settings.database_url), pool_pre_ping=True) | |
| AsyncSessionLocal = async_sessionmaker(engine, expire_on_commit=False) | |
| async def get_session() -> AsyncIterator[AsyncSession]: | |
| async with AsyncSessionLocal() as session: | |
| yield session | |