修复健康监控

This commit is contained in:
2026-04-01 16:37:23 +08:00
parent c4ad386b9f
commit c0cfc4ba9f

View File

@@ -25,6 +25,7 @@ from .routers.v1 import (
auth_router, user_router, todos_router,
notes_router, tools_router, stats_router
)
from sqlalchemy import text
@asynccontextmanager
@@ -90,7 +91,8 @@ app.middleware("http")(log_requests)
@app.get("/health")
async def health_check(db: Session = Depends(get_db)):
try:
db.execute("SELECT 1")
# 使用 text() 包裹 SQL 语句
db.execute(text("SELECT 1"))
return {
"status": "healthy",
"database": "connected",