Re: Re: psycopg3 transactions

Поиск
Список
Период
Сортировка
От Daniele Varrazzo
Тема Re: Re: psycopg3 transactions
Дата
Msg-id CA+mi_8aK5UPGfBjxPYPkGKbHM+JWbqMAS5zCB7LECRDbRQrXHA@mail.gmail.com
обсуждение исходный текст
Ответ на Aw: Re: psycopg3 transactions  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Ответы Re: Re: psycopg3 transactions  (Magnus Hagander <magnus@hagander.net>)
Список psycopg
On Thu, 21 Oct 2021 at 12:06, Karsten Hilbert <Karsten.Hilbert@gmx.net> wrote:
>
> > The behaviour of a dbapi connection, without context block, is to just close the communication. The fact that this
resultsin a rollback > stems only from the behaviour of the server
 
>
> But that's the whole point?   A driver should _not_ (by default) alter the default
> behaviour of the other end, IMO, without extremely good reason. There _is_ good
> reason for the transaction context manager, but not for the connection context
> manager or plain use.

The implicit BEGIN is also a surprising change from the "natural
course of events". Psycopg can still be used as a driver and not alter
the natural course of events. I have extended the documentation
(https://www.psycopg.org/psycopg3/docs/basic/usage.html#connection-context)
both highlighting the difference in behaviour you reported and
suggesting to not use 'with' in case more control is needed (using
psycopg more as a driver than as the end user).


> > asking that the program to 'conn.commit()' explicitly seems an unrequested, kinda ritual, final blessing.
>
> Exactly.
>
> > Sending an explicit ROLLBACK is an occurrence much more rare,
>
> Exactly, and thusly easily forgotten, with possibly dire consequences
> (in the case of default-commit, as opposed to default-rollback).

On this I disagree. People forget to do things when they are a
repetitive common occurrence, not when they are extraordinary.

I don't really see a disaster occurring there, especially because
porting code from psycopg2 results in pretty much the same operations.


-- Daniele



В списке psycopg по дате отправления:

Предыдущее
От: Karsten Hilbert
Дата:
Сообщение: Aw: Re: psycopg3 transactions
Следующее
От: Magnus Hagander
Дата:
Сообщение: Re: Re: psycopg3 transactions