public inbox for [email protected]  
help / color / mirror / Atom feed
From: Daniel Fortunov <[email protected]>
To: Daniele Varrazzo <[email protected]>
Cc: Paolo De Stefani <[email protected]>
Cc: Psycopg <[email protected]>
Subject: Re: psycopg3 transactions
Date: Thu, 14 Oct 2021 00:28:11 +0100
Message-ID: <CAH1rg6ZoQm=STwMR6AQ_FggxRxUn7qH_tLkRTfJTVYYdbTeL6w@mail.gmail.com> (raw)
In-Reply-To: <CA+mi_8afF2jMifiLSvL99+Ztupy1me7xDNAv0g47WxHWbwN9vw@mail.gmail.com>
References: <[email protected]>
	<CA+mi_8bXjHTrzDLQ+n_6K2MHVsr0J32X1HA28Ey9O+-Zm6JaeQ@mail.gmail.com>
	<[email protected]>
	<CA+mi_8afF2jMifiLSvL99+Ztupy1me7xDNAv0g47WxHWbwN9vw@mail.gmail.com>

On Wed, 13 Oct 2021 at 20:06, Daniele Varrazzo <[email protected]>
wrote:

>
> I think we can improve the documentation there by extending more about
> the effects of the interaction between DBAPI transactions and the
> transaction() blocks. And things are definitely more intuitive if
> transaction() is used in autocommit: we might want to advise people to
> do that.
>

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


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], [email protected]
  Subject: Re: psycopg3 transactions
  In-Reply-To: <CAH1rg6ZoQm=STwMR6AQ_FggxRxUn7qH_tLkRTfJTVYYdbTeL6w@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