[Tutor] is there a way to convert psycopg2.DatabaseError to string
Cal97g .
cal.97g at gmail.com
Tue Oct 22 08:17:06 EDT 2019
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> 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
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list