Example to create a connection and print the exception if it fails:
import traceback import psycopg2 try: conn = psycopg2.connect( "dbname='modeler' user='postgres' host='host.minikube.internal' " "port='5433' password='secret', " ) print(f"conn={conn}") except Exception as e: print(traceback.format_exc()) try: conn = psycopg2.connect( "dbname='modeler' " "user='v-kubernet-my-role-tIuMHj1twcxt4KMcHe6w-1725281813' " "host='host.minikube.internal' " "port='5433' " "password='CGX09V-5C9pTS2Y-wpHd' " "options='-c search_path=airflow'", ) print(f"conn={conn}") except Exception as e: print(traceback.format_exc()) |