Spaces:
Sleeping
Sleeping
Download app/models/database.py from GodRad/Rag_SaaS_Sys_V4: direct link, hf CLI and curl.
- Browser
- Download file 529 Bytes
-
https://huggingface.co/spaces/GodRad/Rag_SaaS_Sys_V4/resolve/main/app/models/database.py
- Command line
-
hf download hf://spaces/GodRad/Rag_SaaS_Sys_V4/app/models/database.py
-
curl -L -o database.py https://huggingface.co/spaces/GodRad/Rag_SaaS_Sys_V4/resolve/main/app/models/database.py
529 Bytes
| from sqlalchemy import create_engine | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy.orm import sessionmaker | |
| from app.core.config import settings | |
| engine = create_engine( | |
| settings.DATABASE_URL, connect_args={"check_same_thread": False} if "sqlite" in settings.DATABASE_URL else {} | |
| ) | |
| SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) | |
| Base = declarative_base() | |
| def get_db(): | |
| db = SessionLocal() | |
| try: | |
| yield db | |
| finally: | |
| db.close() | |