Download backend/database.py from noodledom/focusflow: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/spaces/noodledom/focusflow/resolve/main/backend/database.py
- Command line
-
hf download hf://spaces/noodledom/focusflow/backend/database.py
-
curl -L -o database.py https://huggingface.co/spaces/noodledom/focusflow/resolve/main/backend/database.py
1.5 kB
| from sqlalchemy import create_engine, Column, Integer, String, Boolean, ForeignKey | |
| from sqlalchemy.orm import declarative_base, sessionmaker | |
| DATABASE_URL = "sqlite:///./focusflow.db" | |
| engine = create_engine(DATABASE_URL, connect_args={"check_same_thread": False}) | |
| SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine) | |
| Base = declarative_base() | |
| class Source(Base): | |
| __tablename__ = "sources" | |
| id = Column(Integer, primary_key=True, index=True) | |
| student_id = Column(String, index=True, default="anonymous") | |
| filename = Column(String, index=True) | |
| type = Column(String) # online/offline | |
| file_path = Column(String) | |
| is_active = Column(Boolean, default=True) | |
| class Schedule(Base): | |
| __tablename__ = "schedule" | |
| id = Column(Integer, primary_key=True, index=True) | |
| student_id = Column(String, index=True, default="anonymous") | |
| date = Column(String, index=True) # YYYY-MM-DD | |
| topic_name = Column(String) | |
| is_completed = Column(Boolean, default=False) | |
| is_locked = Column(Boolean, default=True) | |
| class Mastery(Base): | |
| __tablename__ = "mastery" | |
| id = Column(Integer, primary_key=True, index=True) | |
| student_id = Column(String, index=True, default="anonymous") | |
| topic_name = Column(String, index=True) | |
| quiz_score = Column(Integer, default=0) | |
| flashcard_status = Column(String, default="Not Started") | |
| # Create tables | |
| def init_db(): | |
| Base.metadata.create_all(bind=engine) | |
| if __name__ == "__main__": | |
| init_db() | |