postgresql - get psycopg2 errors in python3 -
i've psycopg2 version 2.6.1 want fetch errors, dont work excpected:
try: pgconn = psycopg2.connect(database="foobar", host="dbtest.example.de", user="postgresss") except psycopg2.operationalerror: print(psycopg2.operationalerror.pgerror) .....: <member 'pgerror' of 'psycopg2.error' objects>
or:
try: pgconn = psycopg2.connect(database="foobar", host="dbtest.example.de", user="postgresss") except psycopg2.operationalerror: print(psycopg2.operationalerror.diag) .....: <attribute 'diag' of 'psycopg2.error' objects>
how can see correct message "no pg_hba.conf entry host xyz"
you need reference exception instance:
try: pgconn = psycopg2.connect(database="foobar", host="dbtest.example.de", user="postgresss") except psycopg2.operationalerror e: print(e)
Comments
Post a Comment