Spaces:
Paused
Paused
File size: 627 Bytes
04367dd | 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 | """Check PostgreSQL connectivity for SQLSage manually."""
from __future__ import annotations
import os
import psycopg2
def main() -> None:
conn = psycopg2.connect(
host=os.getenv("POSTGRES_HOST", "localhost"),
port=int(os.getenv("POSTGRES_PORT", "5432")),
user=os.getenv("POSTGRES_USER", "postgres"),
password=os.getenv("POSTGRES_PASSWORD", "sqlsage"),
dbname=os.getenv("POSTGRES_DB", "sqlsage"),
)
with conn.cursor() as cur:
cur.execute("SELECT version()")
row = cur.fetchone()
conn.close()
print(row[0])
if __name__ == "__main__":
main()
|