Aw: Re: psycopg3 transactions

From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
Cc: Paolo De Stefani <paolo(at)paolodestefani(dot)it>, Psycopg <psycopg(at)postgresql(dot)org>
Subject: Aw: Re: psycopg3 transactions
Date: 2021-10-21 11:06:34
Message-ID: trinity-b5bbbf6a-2f7d-4865-ad6b-3e846cf58399-1634814394835@3c-app-gmx-bap69
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

> 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 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.

> I think that using 'execute("INSERT....")' is already quite a conscious decision of operating on the database.

I agree. But the decision is not "this IS to be in the database" (or else no need for
transactions) but rather "this is to be in the database IF other, perhaps not even
database related, things suceed".

> 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).

Karsten

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Daniele Varrazzo 2021-10-21 12:00:10 Re: Re: psycopg3 transactions
Previous Message Daniele Varrazzo 2021-10-21 10:52:40 Re: psycopg3 transactions