Spaces:
Sleeping
Sleeping
Download database.py from rabbydatainsight/lumora_backend: direct link, hf CLI and curl.
- Browser
- Download file 648 Bytes
-
https://huggingface.co/spaces/rabbydatainsight/lumora_backend/resolve/main/database.py
- Command line
-
hf download hf://spaces/rabbydatainsight/lumora_backend/database.py
-
curl -L -o database.py https://huggingface.co/spaces/rabbydatainsight/lumora_backend/resolve/main/database.py
648 Bytes
| from sqlalchemy import create_engine | |
| from sqlalchemy.orm import sessionmaker, declarative_base | |
| import os | |
| # In production (Render), set DATABASE_URL env var to a Postgres URL. | |
| # Falls back to local SQLite for development. | |
| SQLALCHEMY_DATABASE_URL = os.getenv( | |
| "DATABASE_URL", | |
| "sqlite:///./emotion_system.db" | |
| ) | |
| # SQLite needs check_same_thread; Postgres does not | |
| connect_args = {"check_same_thread": False} if SQLALCHEMY_DATABASE_URL.startswith("sqlite") else {} | |
| engine = create_engine(SQLALCHEMY_DATABASE_URL, connect_args=connect_args) | |
| SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) | |
| Base = declarative_base() | |