diff --git a/__pycache__/supabase.cpython-313.pyc b/__pycache__/supabase.cpython-313.pyc new file mode 100644 index 0000000..314fde8 Binary files /dev/null and b/__pycache__/supabase.cpython-313.pyc differ diff --git a/supabase.py b/supabase.py index e69de29..07441be 100644 --- a/supabase.py +++ b/supabase.py @@ -0,0 +1,22 @@ +import psycopg2 +import os + +def get_db_connection(): + db_uri = os.getenv("DB_URI") + print("test") + if not db_uri: + raise ValueError("DB_URI 환경변수 없음.") + + try: + conn = psycopg2.connect(db_uri) + cursor = conn.cursor() + cursor.execute("SELECT version();") + db_version = cursor.fetchone() + print(f"Connected to the database. Version: {db_version[0]}") + + cursor.close() + conn.close() + + except Exception as e: + print(f"Error connecting to the database: {e}") + raise \ No newline at end of file