On Wed, 13 Oct 2021 at 15:21, Paolo De Stefani <pa...@paolodestefani.it> wrote:

> I was used to wrote a "with con.cursor() as cur:" that now i hato to
> replace with:
>
> with con.transaction():
>      with con.cursor() as cur:
>          cur.execute("ANY SQL STATEMENT")
>
> and everything works as expected (or i expect...)

You can even write:

    with con.transaction():
        con.execute("ANY SQL STATEMENT")

But is it even useful to wrap a transaction around any single
statement? I still think you'd be better off with an autocommit
connection.

-- Daniele


Reply via email to