public inbox for [email protected]
help / color / mirror / Atom feedFrom: Paolo De Stefani <[email protected]>
To: Psycopg <[email protected]>
Subject: exception psycopg.Error from psycopg2 to psycopg 3
Date: Fri, 11 Feb 2022 18:33:39 +0100
Message-ID: <[email protected]> (raw)
Hi all
Porting my program from psycopg2 to psycopg 3 i found another different
behaviour
This SQL code inside a function:
RAISE EXCEPTION 'Error wrong database' USING HINT = 'You need to use a
different database', ERRCODE = 'PA002';
is catched in python code with:
try:
<execute sql function>
except psycopg.Error as er:
raise PyAppDBError(er.sqlstate, er)
With psycopg2 er.sqlstate is set to 'PA002' in psycopg3 is set to None
Is this an expected behavour ? Is there a way to get the error code in
psycopg3 like it is available in psycopg2 ?
Or maybe Am I doing something wrong ?
Thanks
--
Paolo De Stefani
view thread (5+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: exception psycopg.Error from psycopg2 to psycopg 3
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox