Sujet : Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.pythonDate : 09. Sep 2024, 23:05:34
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vbnnuu$2i1cc$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14
User-Agent : Pan/0.160 (Toresk; )
On Mon, 9 Sep 2024 10:00:11 -0000 (UTC), Jon Ribbens wrote:
On 2024-09-09, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>
The database only needs to commit when it is explicitly told. Anything
less -- no commit.
So the Python code is half-way through a transaction when it throws a
(non-database-related) exception and that thread of execution is
aborted. The database connection returns to the pool ...
The DBMS connection is deleted. The DBMS discards all context created for
this connection, including any transactions in progress. Gone.
The database structures on persistent storage are also carefully designed
with transaction safety in mind. So any partial transaction data saved on
persistent storage that remains after a system crash can be identified as
such and discarded, leaving the database in its pre-transaction state.