Re: psycopg3 transactions

From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: Daniel Fortunov <postgresql(at)danielfortunov(dot)com>, Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>, Paolo De Stefani <paolo(at)paolodestefani(dot)it>, Psycopg <psycopg(at)postgresql(dot)org>
Subject: Re: psycopg3 transactions
Date: 2021-10-16 22:29:45
Message-ID: YWtSWe7xYua37Tnv@hermes.hilbert.loc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

Am Thu, Oct 14, 2021 at 03:38:21PM -0700 schrieb Adrian Klaver:

> >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.
>
> If I'm following that option exists:
>
> https://www.psycopg.org/psycopg3/docs/api/connections.html#psycopg.Connection.transaction
>
> force_rollback (bool) – Roll back the transaction at the end of the block even if there
> were no error (e.g. to try a no-op process).

Yes, but I would argue that force_rollback=True should be the
default.

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

In response to

Browse psycopg by date

  From Date Subject
Next Message Karsten Hilbert 2021-10-16 22:48:40 Re: psycopg3 transactions
Previous Message Daniele Varrazzo 2021-10-16 09:59:33 Re: psycopg3 transactions