feat: 接入mysql数据库

This commit is contained in:
2026-09-04 17:01:12 +08:00
parent 38310f7b1c
commit 86a0d64182
22 changed files with 765 additions and 146 deletions

24
service/report_service.py Normal file
View File

@@ -0,0 +1,24 @@
import json
from sqlalchemy import select
from sqlalchemy.orm import Session
from models.health import Report
def upload_report(report: str, db: Session):
report = Report(
content=json.loads(report),
)
db.add(report)
db.commit()
db.refresh(report)
return True
def query_report(id: int, db: Session):
result = db.execute(
select(Report).where(Report.id == id)
)
return result.scalar_one_or_none()