Spaces:
Runtime error
Runtime error
Download database/database.py from mohit112233/vidstream-backend: direct link, hf CLI and curl.
- Browser
- Download file 458 Bytes
-
https://huggingface.co/spaces/mohit112233/vidstream-backend/resolve/main/database/database.py
- Command line
-
hf download hf://spaces/mohit112233/vidstream-backend/database/database.py
-
curl -L -o database.py https://huggingface.co/spaces/mohit112233/vidstream-backend/resolve/main/database/database.py
458 Bytes
| from sqlmodel import create_engine, SQLModel | |
| from sqlmodel.orm import session | |
| from config import settings | |
| DATABASE_URL = settings.database_url | |
| engine = create_engine(DATABASE_URL) | |
| SessionLocal = session.Session(autocommit=False, autoflush=False, bind=engine) | |
| async def init_db(): | |
| SQLModel.metadata.create_all(engine) | |
| print("Databse initialize....") | |
| def get_session(): | |
| db = SessionLocal | |
| try: | |
| yield db | |
| finally: | |
| db.close() |