File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -69,27 +69,29 @@ DATABASE_PASSWORD=os.getenv('DATABASE_PASSWORD')
6969DATABASE_OPTIONS=os.getenv('DATABASE_OPTIONS')
7070try:
7171 options = json.loads(DATABASE_OPTIONS or "{}")
72- psycopg.connect(
72+ conn = psycopg.connect(
7373 dbname=DATABASE_NAME,
7474 user=DATABASE_USER,
7575 password=DATABASE_PASSWORD,
7676 host=DATABASE_HOST,
7777 port=DATABASE_PORT,
7878 **options
7979 )
80+ conn.close()
8081except Exception as e:
8182 print(f"Error: Failed to connect to the postgresql database at {DATABASE_HOST}")
8283 print("Please see the error below for more details:")
8384 print(e)
8485 print("Trying again without any DATABASE_OPTIONS:")
8586 try:
86- psycopg.connect(
87+ conn = psycopg.connect(
8788 dbname=DATABASE_NAME,
8889 user=DATABASE_USER,
8990 password=DATABASE_PASSWORD,
9091 host=DATABASE_HOST,
9192 port=DATABASE_PORT,
9293 )
94+ conn.close()
9395 except Exception as e:
9496 print(f"Error: Failed to connect to the postgresql database at {DATABASE_HOST} without the {DATABASE_OPTIONS}")
9597 print("Please see the error below for more details:")
@@ -109,9 +111,10 @@ except ImportError:
109111import os
110112DATABASE_URL=os.getenv('DATABASE_URL')
111113try:
112- psycopg.connect(
114+ conn = psycopg.connect(
113115 DATABASE_URL
114116 )
117+ conn.close()
115118except psycopg.OperationalError as e:
116119 print(f"Error: Failed to connect to the postgresql database at {DATABASE_URL}")
117120 print("Please see the error below for more details:")
You can’t perform that action at this time.
0 commit comments