Re: Re: psycopg3 transactions

2021-10-21 Thread Magnus Hagander
On Thu, Oct 21, 2021 at 2:00 PM Daniele Varrazzo wrote: > On Thu, 21 Oct 2021 at 12:06, Karsten Hilbert > wrote: > > > > > The behaviour of a dbapi connection, without context block, is to just > close the communication. The fact that this results in a rollback > stems > only from the behaviour

Re: Re: psycopg3 transactions

2021-10-21 Thread Daniele Varrazzo
On Thu, 21 Oct 2021 at 12:06, Karsten Hilbert wrote: > > > The behaviour of a dbapi connection, without context block, is to just > > close the communication. The fact that this results in a rollback > stems > > only from the behaviour of the server > > But that's the whole point? A driver sho

Re: Re: psycopg3 transactions

2021-10-14 Thread Karsten Hilbert
> We are still "using transactions", just with more precise, more explicit*, > and more flexible* semantics, represented by a context manager. > > Rolling back a transaction is possible by raising a Rollback exception > within a block. > > I hope this answers your question but if not please describ

Re: Re: psycopg3 transactions

2021-10-14 Thread Daniel Fortunov
On Thu, 14 Oct 2021, 11:05 Karsten Hilbert, wrote: > >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.rol