Aw: Re: psycopg3 transactions - Mailing list psycopg

From Karsten Hilbert
Subject Aw: Re: psycopg3 transactions
Date
Msg-id trinity-b5bbbf6a-2f7d-4865-ad6b-3e846cf58399-1634814394835@3c-app-gmx-bap69
Whole thread Raw
In response to Re: psycopg3 transactions  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
Responses Re: Re: psycopg3 transactions
List psycopg
> 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.

> 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



psycopg by date:

Previous
From: Daniele Varrazzo
Date:
Subject: Re: psycopg3 transactions
Next
From: Daniele Varrazzo
Date:
Subject: Re: Re: psycopg3 transactions