Re: Re: psycopg3 transactions

Поиск
Список
Период
Сортировка
От Karsten Hilbert
Тема Re: Re: psycopg3 transactions
Дата
Msg-id YWisObvZJNvpihtM@hermes.hilbert.loc
обсуждение исходный текст
Ответ на Re: Re: psycopg3 transactions  (Daniel Fortunov <postgresql@danielfortunov.com>)
Ответы Re: psycopg3 transactions  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список psycopg
> 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 describe the scenario
> you are thinking about.

Personally, I think the autocommit=False approach is somewhat
safer (more conservative) for the data:

    One *always* is inside a transaction, and the default
    behaviour is to rollback.

    Nothing is by accident automatically committed -- which can
    happen with autocommit=True.

I would certainly suggest that a context manager calls
.rollback() during teardown rather than .commit() -- the
context manager cannot know whether actions really are to
be committed, even if technically possible.

Karsten
--
GPG  40BE 5B0E C98E 1713 AFA6  5BC0 3BEA AC80 7D4F C89B



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

Предыдущее
От: Daniel Fortunov
Дата:
Сообщение: Re: Re: psycopg3 transactions
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: psycopg3 transactions