From 652f32404a100b16727f0e7783b26c1ef8188726 Mon Sep 17 00:00:00 2001 From: Automated Action Date: Mon, 12 May 2025 14:08:39 +0000 Subject: [PATCH] Fix database health check by adding commit after query execution --- app/api/health.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/api/health.py b/app/api/health.py index 9406aed..5d5dd52 100644 --- a/app/api/health.py +++ b/app/api/health.py @@ -1,5 +1,6 @@ from fastapi import APIRouter, Depends from sqlalchemy.orm import Session +from sqlalchemy import text from datetime import datetime from app.db.session import get_db @@ -13,11 +14,12 @@ def health_check(db: Session = Depends(get_db)): """ try: # Check database connection - db.execute("SELECT 1") + db.execute(text("SELECT 1")) + db.commit() db_status = "healthy" except Exception as e: db_status = f"unhealthy: {str(e)}" - + return { "status": "healthy", "timestamp": datetime.utcnow(),