Spaces:
Sleeping
Sleeping
Download build/lib/core/database.py from hashir-qt/tasklert-api: direct link, hf CLI and curl.
- Browser
- Download file 482 Bytes
-
https://huggingface.co/spaces/hashir-qt/tasklert-api/resolve/main/build/lib/core/database.py
- Command line
-
hf download hf://spaces/hashir-qt/tasklert-api/build/lib/core/database.py
-
curl -L -o database.py https://huggingface.co/spaces/hashir-qt/tasklert-api/resolve/main/build/lib/core/database.py
482 Bytes
| from typing import AsyncGenerator | |
| from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine | |
| from .config import settings | |
| engine = create_async_engine( | |
| settings.database_url, | |
| echo=settings.debug, | |
| pool_pre_ping=True, | |
| ) | |
| async_session = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit=False) | |
| async def get_session() -> AsyncGenerator[AsyncSession, None]: | |
| async with async_session() as session: | |
| yield session | |