Spaces:
Sleeping
Sleeping
Download database/session.py from hisham-cmd/GrowthPanelBackend: direct link, hf CLI and curl.
- Browser
- Download file 533 Bytes
-
https://huggingface.co/spaces/hisham-cmd/GrowthPanelBackend/resolve/main/database/session.py
- Command line
-
hf download hf://spaces/hisham-cmd/GrowthPanelBackend/database/session.py
-
curl -L -o session.py https://huggingface.co/spaces/hisham-cmd/GrowthPanelBackend/resolve/main/database/session.py
533 Bytes
| from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession | |
| from sqlalchemy.orm import sessionmaker | |
| import os | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| DATABASE_URL = os.getenv("DATABASE_URL", "postgresql+asyncpg://admin:admin123@localhost:5432/growth_panel_db") | |
| engine = create_async_engine(DATABASE_URL, echo=True) | |
| AsyncSessionLocal = sessionmaker( | |
| engine, class_=AsyncSession, expire_on_commit=False | |
| ) | |
| async def get_db(): | |
| async with AsyncSessionLocal() as session: | |
| yield session | |