public inbox for [email protected]
help / color / mirror / Atom feedFrom: Daniele Varrazzo <[email protected]>
To: Paolo De Stefani <[email protected]>
Cc: Psycopg <[email protected]>
Subject: Re: psycopg3 transactions
Date: Wed, 13 Oct 2021 15:46:46 +0200
Message-ID: <CA+mi_8Z2FT4bHN1yTiM=aS8BXkbiZLwP=KLasXGQPgBRoDPrMg@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
<CA+mi_8bXjHTrzDLQ+n_6K2MHVsr0J32X1HA28Ey9O+-Zm6JaeQ@mail.gmail.com>
<[email protected]>
<CA+mi_8afF2jMifiLSvL99+Ztupy1me7xDNAv0g47WxHWbwN9vw@mail.gmail.com>
<[email protected]>
On Wed, 13 Oct 2021 at 15:21, Paolo De Stefani <[email protected]> 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
view thread (28+ 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], [email protected]
Subject: Re: psycopg3 transactions
In-Reply-To: <CA+mi_8Z2FT4bHN1yTiM=aS8BXkbiZLwP=KLasXGQPgBRoDPrMg@mail.gmail.com>
* 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