On 9/7/24 08:48, Karsten Hilbert wrote:
Dear all,

unto now I had been thinking this is a wise idiom (in code
that needs not care whether it fails to do what it tries to
do^1):

        conn = psycopg2.connection(...)

In the above do you have:

https://www.psycopg.org/docs/extensions.html#psycopg2.extensions.ISOLATION_LEVEL_SERIALIZABLE

psycopg2.extensions.ISOLATION_LEVEL_SERIALIZABLE

Or is that in some other concurrent transaction?

        curs = conn.cursor()
        try:
                curs.execute(SOME_SQL)
        except PSYCOPG2-Exception:
                some logging being done, and, yes, I
                can safely inhibit propagation^1
        finally:
                conn.commit()           # will rollback, if SOME_SQL failed

It will if you use with conn:, otherwise it up to you to do the rollback()

Are you are doing a rollback() in except PSYCOPG2-Exception: ?



--
Adrian Klaver
adrian.kla...@aklaver.com



Reply via email to