24 lines
645 B
Python
24 lines
645 B
Python
import os
|
|
import sys
|
|
|
|
try:
|
|
import psycopg
|
|
except ImportError:
|
|
sys.stderr.write("Missing dependency: install with `python -m pip install psycopg[binary]`\n")
|
|
sys.exit(1)
|
|
|
|
DSN = os.environ.get("SUPABASE_DB_URL")
|
|
if not DSN:
|
|
sys.stderr.write("SUPABASE_DB_URL environment variable is not set.\n")
|
|
sys.exit(1)
|
|
|
|
try:
|
|
with psycopg.connect(DSN, autocommit=True) as conn:
|
|
with conn.cursor() as cur:
|
|
cur.execute("select 1;")
|
|
row = cur.fetchone()
|
|
print("Query result:", row[0] if row else None)
|
|
except Exception as exc:
|
|
sys.stderr.write(f"Connection failed: {exc}\n")
|
|
sys.exit(1)
|