Download backend/app/database.py from xunwei/fitAI: direct link, hf CLI and curl.
- Browser
- Download file 468 Bytes
-
https://huggingface.co/spaces/xunwei/fitAI/resolve/main/backend/app/database.py
- Command line
-
hf download hf://spaces/xunwei/fitAI/backend/app/database.py
-
curl -L -o database.py https://huggingface.co/spaces/xunwei/fitAI/resolve/main/backend/app/database.py
468 Bytes
| from sqlalchemy import create_engine | |
| from sqlalchemy.orm import sessionmaker, DeclarativeBase | |
| SQLALCHEMY_DATABASE_URL = "sqlite:///./sql_app.db" # Default for dev | |
| engine = create_engine(SQLALCHEMY_DATABASE_URL, connect_args={"check_same_thread": False}) | |
| SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) | |
| class Base(DeclarativeBase): | |
| pass | |
| def get_db(): | |
| db = SessionLocal() | |
| try: | |
| yield db | |
| finally: | |
| db.close() | |