feat:更新数据表结构

This commit is contained in:
2026-08-09 14:02:20 +08:00
parent 0760f53cc6
commit 2f4fa66190
15 changed files with 270 additions and 211 deletions

View File

@@ -0,0 +1,13 @@
from sqlalchemy import select
from sqlalchemy.ext.asyncio import AsyncSession
from models.library import Subject
async def get_subject_by_name(db: AsyncSession, subject: str) -> int:
stmt = select(Subject).where(Subject.name == subject)
subject = (await db.execute(stmt)).scalar_one_or_none()
if not subject:
raise ValueError("Subject not found")
return subject.id