psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
Jon Ribbens
jon+usenet at unequivocal.eu
Mon Sep 9 05:13:40 EDT 2024
On 2024-09-08, Lawrence D'Oliveiro <ldo at nz.invalid> wrote:
> On Sun, 8 Sep 2024 11:03:21 -0000 (UTC), Jon Ribbens wrote:
>> What if there's an exception in your exception handler? I'd put the
>> rollback in the 'finally' handler, so it's always called. If you've
>> already called 'commit' then the rollback does nothing of course.
>
> In any DBMS worth its salt, rollback is something that happens
> automatically if the transaction should fail to complete for any reason.
>
> This applies for any failure reason, up to and including a program or
> system crash.
If it's a program or system crash, sure, but anything less than that -
how would the database even know, unless the program told it?
More information about the Python-list
mailing list