Spaces:
Sleeping
Sleeping
File size: 1,407 Bytes
e4e8a91 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | import sys
import os
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from backend.core.config import settings
from backend.persistence.mysql_connection import engine
from sqlalchemy import text
def main():
print("Using DB settings:")
print(" host:", settings.DB_HOST)
print(" port:", settings.DB_PORT)
print(" name:", settings.DB_NAME)
print(" user:", settings.DB_USERNAME)
print(" ssl_ca:", settings.DB_SSL_CA)
# check for ca file
possible_paths = [
Path(settings.DB_SSL_CA),
Path(__file__).resolve().parent.parent / settings.DB_SSL_CA,
Path(__file__).resolve().parent / settings.DB_SSL_CA,
]
found = None
for p in possible_paths:
if p.exists():
found = p
break
if found:
print("Found CA file at:", found)
else:
print("CA file not found in project paths; SSL may still work if DB does not require CA file")
print("Attempting DB connection (this may take a few seconds)...")
try:
with engine.connect() as conn:
# simple test query
res = conn.execute(text("SELECT 1")).scalar()
print("Query result:", res)
print("Connection successful.")
except Exception as e:
print("Connection failed:", type(e).__name__, str(e))
if __name__ == "__main__":
main()
|