Files
secondary-school-grade-archive/backend/app/services/seed.py
T
dekun e329d3398a Initial commit: secondary school grade archive system.
Add FastAPI/React app with Docker deployment, Ubuntu one-click install, and docs for junior/senior high score tracking and mistake bank.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-28 11:18:58 +08:00

24 lines
466 B
Python

from sqlalchemy.orm import Session
from app.models.user import Subject
DEFAULT_SUBJECTS = [
"语文",
"数学",
"英语",
"物理",
"化学",
"生物",
"历史",
"地理",
"政治",
]
def seed_subjects(db: Session) -> None:
existing = {s.name for s in db.query(Subject).all()}
for name in DEFAULT_SUBJECTS:
if name not in existing:
db.add(Subject(name=name))
db.commit()