public inbox for [email protected]
help / color / mirror / Atom feedFrom: Reuben Rissler <[email protected]>
To: [email protected]
Subject: Re: psycopg3 transactions
Date: Wed, 13 Oct 2021 20:14:53 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAH1rg6ZoQm=STwMR6AQ_FggxRxUn7qH_tLkRTfJTVYYdbTeL6w@mail.gmail.com>
References: <[email protected]>
<CA+mi_8bXjHTrzDLQ+n_6K2MHVsr0J32X1HA28Ey9O+-Zm6JaeQ@mail.gmail.com>
<[email protected]>
<CA+mi_8afF2jMifiLSvL99+Ztupy1me7xDNAv0g47WxHWbwN9vw@mail.gmail.com>
<CAH1rg6ZoQm=STwMR6AQ_FggxRxUn7qH_tLkRTfJTVYYdbTeL6w@mail.gmail.com>
>
> Agree. The DBAPI choice to mandate that autocommit be off by default
> is a strange and unfortunate choice that in my experience leads to a
> never ending series of "surprises" such as this one.
>
> My conclusion is that the only sane thing to do is:
> 1. Only ever create connections in autocommit mode.
> 2. Only ever use `with connection.transaction()` to control transactions.
> 3. Forget that `connection.commit()` and `connection.rollback()`
> exist, and never use them.
>
> I'm in favour of recommending this as strongly as reasonably possible
> in the documentation.
>
> It's a shame that 1 is not the default. So you still have to remember
> to not forget to do this explicitly, every time you create a connection.
>
> Dani
I was going to disagree with this, as some things don't work in an ACID
way in autocommit. Then I read point 2, now I'm going to try this and
see how I like transactions vs commit/rollback.
Reuben Rissler
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: <[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