[Tutor] is there a way to convert psycopg2.DatabaseError to string

Eggo why eggo at hotmail.com
Mon Oct 21 11:19:12 EDT 2019


Hi all,
     Is there a way to convert the pcycopg2 exception DatabaseError subclass to string?  Thank you very much for your advise.

except (Exception, psycopg2.DatabaseError) as error:
      query = "insert into exception (event) value (' " + error + " ')"
      cur.execute(query)
      print(error)

Gary



More information about the Tutor mailing list