Spaces:
Runtime error
Runtime error
Download app/db/database.py from cosmin1769/CalorieTrackerAI-backend: direct link, hf CLI and curl.
- Browser
- Download file 606 Bytes
-
https://huggingface.co/spaces/cosmin1769/CalorieTrackerAI-backend/resolve/main/app/db/database.py
- Command line
-
hf download hf://spaces/cosmin1769/CalorieTrackerAI-backend/app/db/database.py
-
curl -L -o database.py https://huggingface.co/spaces/cosmin1769/CalorieTrackerAI-backend/resolve/main/app/db/database.py
606 Bytes
| from sqlalchemy import create_engine | |
| from sqlalchemy.ext.declarative import declarative_base | |
| from sqlalchemy.orm import sessionmaker | |
| from app.core.config import settings | |
| DATABASE_URL = settings.DATABASE_URL | |
| if DATABASE_URL.startswith("sqlite"): | |
| engine = create_engine(DATABASE_URL, connect_args={"check_same_thread": False}) | |
| else: | |
| if DATABASE_URL.startswith("postgres://"): | |
| DATABASE_URL = DATABASE_URL.replace("postgres://", "postgresql://", 1) | |
| engine = create_engine(DATABASE_URL) | |
| SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) | |
| Base = declarative_base() |