Download database.py from smlflg/StudyAgent: direct link, hf CLI and curl.
- Browser
- Download file 563 Bytes
-
https://huggingface.co/smlflg/StudyAgent/resolve/main/database.py
- Command line
-
hf download hf://smlflg/StudyAgent/database.py
-
curl -L -o database.py https://huggingface.co/smlflg/StudyAgent/resolve/main/database.py
563 Bytes
| from sqlalchemy import create_engine | |
| from sqlalchemy.orm import declarative_base, sessionmaker | |
| DATABASE_URL = "sqlite:///./study_agent.db" | |
| engine = create_engine(DATABASE_URL, connect_args={"check_same_thread": False}) | |
| SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) | |
| Base = declarative_base() | |
| def get_db(): | |
| db = SessionLocal() | |
| try: | |
| yield db | |
| finally: | |
| db.close() | |
| def create_all(): | |
| from models import Subject, Deadline, MicroStep, StudySession # noqa: F401 | |
| Base.metadata.create_all(bind=engine) | |