[Tutor] is there a way to convert psycopg2.DatabaseError to string
Eggo why
eggo at hotmail.com
Tue Oct 22 09:40:13 EDT 2019
Thanks it works.
________________________________
From: Cal97g . <cal.97g at gmail.com>
Sent: Tuesday, October 22, 2019 12:17 PM
To: Eggo why <eggo at hotmail.com>
Cc: tutor at python.org <tutor at python.org>
Subject: Re: [Tutor] is there a way to convert psycopg2.DatabaseError to string
try print(error.msg) or print(str(error))
Many Thanks
Callam Delaney
On Mon, 21 Oct 2019 at 21:49, Eggo why <eggo at hotmail.com<mailto:eggo at hotmail.com>> wrote:
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
_______________________________________________
Tutor maillist - Tutor at python.org<mailto:Tutor at python.org>
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list