Re: exception psycopg.Error from psycopg2 to psycopg 3

2022-02-11 Thread Paolo De Stefani
Yes perfect solution for me Thank your the lightspeed response.. Il 11/02/2022 19:47 Daniele Varrazzo ha scritto: On Fri, 11 Feb 2022 at 18:34, Paolo De Stefani wrote: Hi Paolo, Yes, I can see some inconsistency there. At the moment I suggest you use `e.diag.sqlstate`, which works as expecte

Re: exception psycopg.Error from psycopg2 to psycopg 3

2022-02-11 Thread Daniele Varrazzo
On Fri, 11 Feb 2022 at 19:47, Daniele Varrazzo wrote: > ISTM that setting e.sqlstate = e.diag.sqlstate would be an > improvement. https://github.com/psycopg/psycopg/issues/225 -- Daniele

Re: exception psycopg.Error from psycopg2 to psycopg 3

2022-02-11 Thread Daniele Varrazzo
On Fri, 11 Feb 2022 at 18:34, Paolo De Stefani wrote: Hi Paolo, Yes, I can see some inconsistency there. At the moment I suggest you use `e.diag.sqlstate`, which works as expected and is available in psycopg2 too. In [8]: try: cnn.execute(""" ...: do $$ ...: begin ...: RAI

exception psycopg.Error from psycopg2 to psycopg 3

2022-02-11 Thread Paolo De Stefani
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: except psycopg.