Files

27 lines
769 B
Python

"""Health service for business logic."""
from sqlalchemy.orm import Session
from sqlalchemy import text
class HealthService:
"""Service for health check operations."""
@staticmethod
def check_database(db: Session) -> bool:
"""Check if database connection is healthy."""
try:
db.execute(text("SELECT 1"))
return True
except Exception:
return False
@staticmethod
def get_health_status(db: Session) -> dict:
"""Get the health status of the application."""
db_healthy = HealthService.check_database(db)
return {
"status": "healthy" if db_healthy else "unhealthy",
"database": "connected" if db_healthy else "disconnected"
}