Initial commit of akmon project
This commit is contained in:
23
scripts/test_supabase_connection.py
Normal file
23
scripts/test_supabase_connection.py
Normal file
@@ -0,0 +1,23 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user