Files
ai-exchange/scripts/check_db_connection.py
T
2026-04-24 13:39:01 +08:00

22 lines
475 B
Python

from pathlib import Path
import sys
from sqlalchemy import text
ROOT = Path(__file__).resolve().parents[1]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from src.db.engine import engine
def main() -> None:
with engine.connect() as conn:
result = conn.execute(text("select 1"))
value = result.scalar_one()
print("DB connection OK" if value == 1 else "DB connection unexpected result")
if __name__ == "__main__":
main()