Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #427: network down, IP packets delivered via UPS


comp / comp.lang.python / Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)

SubjectAuthor
* Re: psycopg2: proper positioning of .commit() within try: except: blocksKarsten Hilbert
`* Re: psycopg2: proper positioning of .commit() within try: except: blocksGreg Ewing
 +* Re: psycopg2: proper positioning of .commit() within try: except: blocksJon Ribbens
 |+- Re: psycopg2: proper positioning of .commit() within try: except: blocksStefan Ram
 |+* Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)Lawrence D'Oliveiro
 ||`* Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)Jon Ribbens
 || `* Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)Lawrence D'Oliveiro
 ||  `* Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)Jon Ribbens
 ||   +- Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)Karsten Hilbert
 ||   +* Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)Karsten Hilbert
 ||   |`- Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)Jon Ribbens
 ||   `* Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)Lawrence D'Oliveiro
 ||    `* Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)Jon Ribbens
 ||     `* Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)Lawrence D'Oliveiro
 ||      `* Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)Jon Ribbens
 ||       +* Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)Karsten Hilbert
 ||       |`- Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)Jon Ribbens
 ||       `* Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)Lawrence D'Oliveiro
 ||        `* Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)Jon Ribbens
 ||         `* Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)Lawrence D'Oliveiro
 ||          `- Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)Jon Ribbens
 |`- Re: psycopg2: proper positioning of .commit() within try: except: blocksGreg Ewing
 +- Re: psycopg2: proper positioning of .commit() within try: except: blocksKarsten Hilbert
 +- Re: psycopg2: proper positioning of .commit() within try: except: blocksKarsten Hilbert
 `- Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)Lawrence D'Oliveiro

1
Subject: Re: psycopg2: proper positioning of .commit() within try: except: blocks
From: Karsten Hilbert
Newsgroups: comp.lang.python
Date: Sat, 7 Sep 2024 21:20 UTC
References: 1 2 3 4 5 6 7
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: Karsten.Hilbert@gmx.net (Karsten Hilbert)
Newsgroups: comp.lang.python
Subject: Re: psycopg2: proper positioning of .commit() within try: except:
blocks
Date: Sat, 7 Sep 2024 23:20:57 +0200
Lines: 77
Sender: <karsten.hilbert@gmx.net>
Message-ID: <mailman.46.1725744071.2917.python-list@python.org>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de D19ZUoeT47OwkP9pnUuL+wbnvLDmoQbEiOXY939AqHdw==
Cancel-Lock: sha1:2O0LyewjgytIKO+ocNYXWHHc0Io= sha256:GxBC6NK0hhyjdKh9AMareuOILDkMYGrDiVqOqUPHzEc=
Return-Path: <karsten.hilbert@gmx.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmx.net header.i=karsten.hilbert@gmx.net
header.b=C5DT4Hdv; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.002
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'fairly': 0.05;
'received:212.227': 0.07; 'cc:addr:python-list': 0.09; 'gpg':
0.09; 'karsten': 0.09; 'post.': 0.09; 'schrieb': 0.09; 'log':
0.12; 'problem.': 0.15; 'that.': 0.15; '1713': 0.16; '2024': 0.16;
'boring': 0.16; 'choices.': 0.16; 'elsewhere': 0.16; 'ensures':
0.16; 'insufficient': 0.16; 'pythonic': 0.16;
'received:212.227.15': 0.16; 'subject:() ': 0.16;
'subject:proper': 0.16; 'subject:try': 0.16; 'problem': 0.16;
'reached': 0.17; 'cc:addr:python.org': 0.20; 'sat,': 0.22; 'code':
0.23; 'cc:2**1': 0.23; 'actual': 0.25; 'question': 0.32; 'sep':
0.32; 'but': 0.32; 'header:In-Reply-To:1': 0.34; 'best,': 0.38;
'quite': 0.39; 'exact': 0.40; 'something': 0.40; 'best': 0.61;
'sample': 0.61; "there's": 0.61; 'received:212': 0.62; 'involved':
0.63; 'full': 0.64; 'your': 0.64; 'eventually': 0.84;
'exceptions': 0.84; 'handled': 0.84; 'repetitive': 0.84;
'subject:within': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net;
s=s31663417; t=1725744058; x=1726348858; i=karsten.hilbert@gmx.net;
bh=MLHhgDkyrfD78k1nLFaIpMlmvJLWwW2l1U4ZWrWfwxw=;
h=X-UI-Sender-Class:Date:From:To:Cc:Subject:Message-ID:References:
MIME-Version:Content-Type:In-Reply-To:Content-Transfer-Encoding:
cc:content-transfer-encoding:content-type:date:from:message-id:
mime-version:reply-to:subject:to;
b=C5DT4HdvZGkCanhYkr8pkbTw5eX2nFMlBXdmOBmx/EPaGb0VRFgUZBloV8oOkCv+
gVagqhbFv/bKIded6ukjBmwy4VuEAx/IaS7CZnudVhUcio5jNLeeFZzv+kCFNXBLc
gXH+JdiGasUXCPsGYZIQcNVbsz5g1tG+J6ffzyJbDMeSu4DwMujS1r883MpltIkcq
JbAzNljg9xDnz0Ke+9GPMCIgvPlxtBRznVOmMnLpZNh8IvEVspUHbmHiXw7I3a6sr
BzUz2MFFL8EypwgV+jxxEP+EtsdQpIEs7OUej4CIzdK/m1nZ9hOjyWXbHoLE0omcj
m6b0X8EMsORvS+B73Q==
X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a
Content-Disposition: inline
In-Reply-To: <4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
Ma_X_il-Followup-to: d
Re_X_turn-receipt-to: Karsten.Hilbert@gmx.net
Di_X_sposition-Notification-To: Karsten.Hilbert@gmx.net
X-Confi_X_rm-Reading-To: Karsten.Hilbert@gmx.net
X-Pri_X_ority: 2 (High)
X-Provags-ID: V03:K1:n+/1LV090OC2MIvwe+W7yO36UQhhUzp90RGdb3CH8TMjfUPHkYn
xFl4+gbh0jDGEGPcgtd0AivJVkd434jmUoP7mhSkeIX4wCD3TD0bDvJTzYDptstsLjwZKF5
ZJMV6r2Yo2P5iFs/gp6DocHm9rlUbqwb1Oz7Wqml7fdCtMPKNRooSIeyFXCBM/knQRC9PSq
sfd4SVeXYDBMR+mgoWF1w==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:COpfTIja9lQ=;+oZARKcMKelDTecYS72J0YtoEz9
yJ1uLUG79DhWR/svGWgtxRlCr69T7EKImcF4V4LfvzSdo6xYvZYg9sbLWIUrL+SSiK0+doVAT
HwF8gmSUEYqKUwKjzG5/nkUotVL6YBwvvgiJK+NeUYI/Jn+zMotU+IzQMgWGoeZlTY33SLkGl
wL+w41ePmvEXekjmEgaY0bWb8w7NDvuaN3NBil88HZU1IYZy9wWTBlzolWuJLXIOOWgET6V97
ljBGf+hKGe+X+cc5S6XirESKyGEOU7JnhW3MbnTfypVOVsOkcWl9Lz58nvMzssuBo2QEUoHXJ
Bt1cPtJByVkPh/EJ6NtKrrcItKCtBVuJLtN95SzohsthUqxGqBEtzE8e1quQDzh8h45MjYFCj
MR2olkOzWwkYnYt6WV3HFCmk8fJnEAI87CL/8lx5yiQPmylvU0AdqnjzPID4aFylxDB9svBY6
GdvCdwftXLDDVFNs7pWGYX0aDwxa2Gp+bB+/ssoc5varwgOmW3V391J5IylinDayQxdsgsGlT
tc05VbxtnwJDXBn1FA+QMM3iZtdlMP7rgAVPSH28MFko3fjMRRzaSsDNwtytXjPRFBnsXIR/8
aNJl2TKaufYBsnXIDZTts+UoetuQdRWHvy/+X/oNFTXg6NMwHX23vwUOUulVRBYc9XVl85/gy
JsSwIC8i14LJpnqbH6IqDGvSySH16CVn5jtVKaQfUnxYYU79jvnM3TT8E482EfkT4kYBEbkNv
6Ch9tOAZV7u2dgMrIlcby38qw86FEgPh45UYyg5r/ttV/YQiB2w8bl0Q7/DjnRl2t83nU4yV9
bMATcUnT6f+teUKVaFl9Wd8w==
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <ZtzDubguRDWXwV-t@hermes.hilbert.loc>
X-Mailman-Original-References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
View all headers

Am Sat, Sep 07, 2024 at 02:09:28PM -0700 schrieb Adrian Klaver:

> >Right, and this was suggested elsewhere ;)
> >
> >And, yeah, the actual code is much more involved :-D
> >
>
> I see that.
>
> The question is does the full code you show fail?
>
> The code sample you show in your original post is doing something very different then
> what you show in your latest post. At this point I do not understand the exact problem
> we are dealing with.

We are not dealing with an unsolved problem. I had been
asking for advice where to best place that .commit() call in
case I am overlooking benefits and drawbacks of choices.

The

try:
do something
except:
log something
finally:
.commit()

cadence is fairly Pythonic and elegant in that it ensures the
the .commit() will always be reached regardless of exceptions
being thrown or not and them being handled or not.

It is also insufficient because the .commit() itself may
elicit exceptions (from the database).

So there's choices:

Ugly:

try:
do something
except:
log something
finally:
try:
.commit()
except:
log some more

Fair but not feeling quite safe:

try:
do something
.commit()
except:
log something

Boring and repetitive and safe(r):

try:
do something
except:
log something
try:
.commit()
except:
log something

I eventually opted for the last version, except for factoring
out the second try: except: block.

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

Subject: Re: psycopg2: proper positioning of .commit() within try: except: blocks
From: Greg Ewing
Newsgroups: comp.lang.python
Date: Sun, 8 Sep 2024 00:48 UTC
References: 1 2 3 4 5 6 7 8
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: greg.ewing@canterbury.ac.nz (Greg Ewing)
Newsgroups: comp.lang.python
Subject: Re: psycopg2: proper positioning of .commit() within try: except:
blocks
Date: Sun, 8 Sep 2024 12:48:50 +1200
Lines: 35
Message-ID: <lk4ajkFbbnrU1@mid.individual.net>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net YYx4jBKGgenJHyqqNH9NWwXnkcZ4zQGOTKQiQ9x8F3tW6jAWaS
Cancel-Lock: sha1:jD+WVfeee//kb396gLNXMgAulGA= sha256:o36aQZXSdRkkQI2ox6f5PhNYRE53ikTqWJDcoGi+WC0=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:91.0)
Gecko/20100101 Thunderbird/91.3.2
Content-Language: en-US
In-Reply-To: <mailman.46.1725744071.2917.python-list@python.org>
View all headers

On 8/09/24 9:20 am, Karsten Hilbert wrote:
> try:
> do something
> except:
> log something
> finally:
> .commit()
>
> cadence is fairly Pythonic and elegant in that it ensures the
> the .commit() will always be reached regardless of exceptions
> being thrown or not and them being handled or not.

That seems wrong to me. I would have thought the commit should only
be attempted if everything went right.

What if there's a problem in your code that causes a non-SQL-related
exception when some but not all of the SQL statements in the
transaction bave been issued? The database doesn't know something
has gone wrong, so it will happily commit a partially-completed
transaction and possibly corrupt your data.

This is how I normally do things like this:

try:
do something
.commit()
except:
log something
.rollback()

Doing an explicit rollback ensures that the transaction is always
rolled back if it is interrupted for any reason.

--
Greg

Subject: Re: psycopg2: proper positioning of .commit() within try: except: blocks
From: Jon Ribbens
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Sun, 8 Sep 2024 11:03 UTC
References: 1 2 3 4 5 6 7 8 9
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jon+usenet@unequivocal.eu (Jon Ribbens)
Newsgroups: comp.lang.python
Subject: Re: psycopg2: proper positioning of .commit() within try: except:
blocks
Date: Sun, 8 Sep 2024 11:03:21 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
Injection-Date: Sun, 08 Sep 2024 13:03:22 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="ba9ce860b6333fc11c869d28301771e8";
logging-data="2006882"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/HfA8OGGhZ+6/J20lNvMVykJHInoyyLcg="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:/Tjrh+FaNljkTcduGH2AZpytSuY=
View all headers

On 2024-09-08, Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
> On 8/09/24 9:20 am, Karsten Hilbert wrote:
>> try:
>> do something
>> except:
>> log something
>> finally:
>> .commit()
>>
>> cadence is fairly Pythonic and elegant in that it ensures the
>> the .commit() will always be reached regardless of exceptions
>> being thrown or not and them being handled or not.
>
> That seems wrong to me. I would have thought the commit should only
> be attempted if everything went right.
>
> What if there's a problem in your code that causes a non-SQL-related
> exception when some but not all of the SQL statements in the
> transaction bave been issued? The database doesn't know something
> has gone wrong, so it will happily commit a partially-completed
> transaction and possibly corrupt your data.
>
> This is how I normally do things like this:
>
> try:
> do something
> .commit()
> except:
> log something
> .rollback()
>
> Doing an explicit rollback ensures that the transaction is always
> rolled back if it is interrupted for any reason.

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.

Subject: Re: psycopg2: proper positioning of .commit() within try: except: blocks
From: Karsten Hilbert
Newsgroups: comp.lang.python
Date: Sun, 8 Sep 2024 11:06 UTC
References: 1 2 3 4 5 6 7 8 9 10
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: Karsten.Hilbert@gmx.net (Karsten Hilbert)
Newsgroups: comp.lang.python
Subject: Re: psycopg2: proper positioning of .commit() within try: except:
blocks
Date: Sun, 8 Sep 2024 13:06:19 +0200
Lines: 46
Sender: <karsten.hilbert@gmx.net>
Message-ID: <mailman.47.1725793582.2917.python-list@python.org>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<Zt2FK_zt9csPjhB-@hermes.hilbert.loc>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de utEjq6I/YcX4ftXohZAJnQTHV6xUDUT0oOkJs1ua8Jug==
Cancel-Lock: sha1:ciWz8bqObCd+Ss+im0yxqZbYS/0= sha256:WQXt4ygyoqAv0opiARlRv7Skrsw3HYpzHX3KbtlYX8s=
Return-Path: <karsten.hilbert@gmx.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmx.net header.i=karsten.hilbert@gmx.net
header.b=lvdyDcOH; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.004
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'fairly': 0.05;
'received:212.227': 0.07; 'sun,': 0.07; ':-)': 0.09; 'gpg': 0.09;
'karsten': 0.09; 'schrieb': 0.09; 'log': 0.12; '1713': 0.16;
'2024': 0.16; 'commit': 0.16; 'ensures': 0.16; 'greg': 0.16;
'hilbert': 0.16; 'ignored': 0.16; 'pythonic': 0.16; 'right.':
0.16; 'subject:() ': 0.16; 'subject:proper': 0.16; 'subject:try':
0.16; 'wrote:': 0.16; 'problem': 0.16; 'reached': 0.17; 'to:addr
:python-list': 0.20; 'exception': 0.22; 'code': 0.23; 'seems':
0.26; 'wrong': 0.28; 'am,': 0.31; "doesn't": 0.32; 'sep': 0.32;
'but': 0.32; 'header:In-Reply-To:1': 0.34; 'possibly': 0.36;
'error,': 0.38; 'data.': 0.40; 'gone': 0.40; 'something': 0.40;
'should': 0.40; "there's": 0.61; 'me.': 0.62; 'received:212':
0.62; 'everything': 0.63; 'skip:r 20': 0.64; 'transaction': 0.64;
'your': 0.64; 'well': 0.65; 'see,': 0.76; 'database': 0.80;
'exceptions': 0.84; 'handled': 0.84; 'subject:within': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net;
s=s31663417; t=1725793580; x=1726398380; i=karsten.hilbert@gmx.net;
bh=e2sc6zm0w6XIqkHGQ23TTzSbKZlmC8/y8M3vq0nmwQo=;
h=X-UI-Sender-Class:Date:From:To:Subject:Message-ID:References:
MIME-Version:Content-Type:In-Reply-To:Content-Transfer-Encoding:
cc:content-transfer-encoding:content-type:date:from:message-id:
mime-version:reply-to:subject:to;
b=lvdyDcOH7r5jr+6y45HhLt/Gn2pt8luv7Fv4MZjWv04SY35fqn1W7Cx7OUJ9HndC
tTJGiuffzN84wSPPSRgnxNL6Hq4IATu7MrUrygGM0Cbk5ndXXPyIKtLPI8LTWv43O
jciEd/3YlSXWhTCHrOIT/WbIyi3dhPJQRdpBqHESblYSd/NQCl1ZA7Xq+1w1H45q2
Tv3XhY9Y4uVk/CwoeeCVQthMTf/mtz8pa6Hc5EfFC0hvze9hD7xf7ESpItTdzA5Vm
2h3w17Zyg31eN/KXgqdpF6J+yH0vKDM6DbnnqsnP++lySeOv4ThcQrGiGLkzHm6uV
hGd+irXL0+NgJVhahg==
X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a
Content-Disposition: inline
In-Reply-To: <lk4ajkFbbnrU1@mid.individual.net>
Ma_X_il-Followup-to: d
Re_X_turn-receipt-to: Karsten.Hilbert@gmx.net
Di_X_sposition-Notification-To: Karsten.Hilbert@gmx.net
X-Confi_X_rm-Reading-To: Karsten.Hilbert@gmx.net
X-Pri_X_ority: 2 (High)
X-Provags-ID: V03:K1:jpNBu5bcziW2im/LUnxmtuDo2P1sYWKNu6T1IwwvXPb4EWrYH8l
W/W+oZAIyDY/LL7C7LAZ1pt2vutZbszTCpFViXnl8uVot/ECCJzsktjJw972aUbczOMYbqW
dYTnt1K8X0ldOaumXWIJC3e1rY5mwJnQtv4i3WIbg9aBdPEB3JrHMsB9vFF+jw24ft8odQI
7YdjSfnTFcg2eT3GDNl1w==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:v6XDTGl6Sds=;ZjayO9rBMpQ5JX7588jERYTm6Me
Rj9Zx6VUUt0IaeKLYnYQhCU91bumf11h1+cXiREGS17bryfx6ijdyVb9qWuOUXGkl++jABF1s
njmR0J+gtKjbG2b0RB5a5Gi6MCL7T1Z5H8fUed8ehr/RQjvwJcDZ17jTXigop0QsgUUrjtFni
LONPWSuIBJAVj3cx2yTaFJDU/bckTHIxGevGLTCrxSYyUhDSoZsrHfT9PXEFpZdLxmvXVyj8Y
ttIB6pdtsdNJjkCJPEBkIkbiXb7j1K5SFgi9vTLvjPUlXZC+02qmqqq0vc1Smdf7HOMsfbr5y
+sro0crriqr9GgLTD/NKzd6qJi/0fbktaOgDOrQBkk8t/u+TtcVdFqiAbUJkAMsZXpz6dAfeu
wCi6Y1m9gBlroZ0x86IJybja9jKWyDgceIBTb65JVEE1HDPU7Tsqq9SfZsF/901WaH8MPWIdj
1927HhhDUJiCDiRXBRQhdGzj6cAexfhR6sTltsMIpVi41I8H9CPk7koTmolqJN0fHgohi2nGG
UnWvrKGjLjTTWRptC9O53Nl+aGK/T42f1bQSIre9bnOxjouLRSQxaGlAKlFCc9WYyYrYv23qY
0QYo3b6IcKUObd66SfBqbbsxRo2rjasuk+5AUewxcRIRCh4SYCfBfWjw8jarQQ1Hi10kxcwv3
P/V5Zal7yToaOZxz3bxys8fTz/VCHpwzGp5dWEILwawBJQ4Ws9YUxDOBGE+NoBxCqcR4aWsQu
wU+DGm6XasZDXR3qdfTWlDo5g+Zi8yBZ60qvmIFign1RZhaDW62X/KG8sKlnlA1W7tdyM8JSA
dR9vZK6IiYLHbgOxEv38sF8w==
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <Zt2FK_zt9csPjhB-@hermes.hilbert.loc>
X-Mailman-Original-References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
View all headers

Am Sun, Sep 08, 2024 at 12:48:50PM +1200 schrieb Greg Ewing via Python-list:

> On 8/09/24 9:20 am, Karsten Hilbert wrote:
> > try:
> > do something
> > except:
> > log something
> > finally:
> > .commit()
> >
> >cadence is fairly Pythonic and elegant in that it ensures the
> >the .commit() will always be reached regardless of exceptions
> >being thrown or not and them being handled or not.
>
> That seems wrong to me. I would have thought the commit should only
> be attempted if everything went right.
>
> What if there's a problem in your code that causes a non-SQL-related
> exception when some but not all of the SQL statements in the
> transaction bave been issued? The database doesn't know something
> has gone wrong, so it will happily commit a partially-completed
> transaction and possibly corrupt your data.

A-ha !

try:
run_some_SQL_that_succeeds()
print(no_such_name) # tongue-in-cheek
1 / 0 # for good measure
except SOME_DB_ERROR:
print('some DB error, can be ignored for now')
finally:
commit()

which is wrong, given that the failing *Python* statements
may very well belong into the *business level* "transaction"
which a/the database transaction is part of.

See, that's why I was asking in the first place :-)

I was overlooking implications.

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

Subject: Re: psycopg2: proper positioning of .commit() within try: except: blocks
From: Karsten Hilbert
Newsgroups: comp.lang.python
Date: Sun, 8 Sep 2024 11:13 UTC
References: 1 2 3 4 5 6 7 8 9 10
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: Karsten.Hilbert@gmx.net (Karsten Hilbert)
Newsgroups: comp.lang.python
Subject: Re: psycopg2: proper positioning of .commit() within try: except:
blocks
Date: Sun, 8 Sep 2024 13:13:37 +0200
Lines: 50
Sender: <karsten.hilbert@gmx.net>
Message-ID: <mailman.48.1725794019.2917.python-list@python.org>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<Zt2G4e7cwTbP3K_b@hermes.hilbert.loc>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de iSr9Izy2/3IPcIwjVXZJVQLQQI3lwGjSHmwYUPmWF5JQ==
Cancel-Lock: sha1:Q9ZVRE5otadAQxvFRfrRhY4PZgM= sha256:jg9lNSr+AKjfyb+d+6Ii5UtOE5RCG22WCeWDxBEdkRM=
Return-Path: <karsten.hilbert@gmx.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmx.net header.i=karsten.hilbert@gmx.net
header.b=t+xxQnGL; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'this:': 0.03; 'fairly':
0.05; ';-)': 0.07; 'received:212.227': 0.07; 'sun,': 0.07;
'fact,': 0.09; 'fails': 0.09; 'fault': 0.09; 'gpg': 0.09;
'implicit': 0.09; 'karsten': 0.09; 'reasoning': 0.09; 'schrieb':
0.09; 'log': 0.12; '1713': 0.16; '2024': 0.16; 'commit': 0.16;
'ensures': 0.16; 'explicit': 0.16; 'greg': 0.16; 'hilbert': 0.16;
'interrupted': 0.16; 'missed': 0.16; 'pattern:': 0.16; 'pythonic':
0.16; 'reason.': 0.16; 'right.': 0.16; 'subject:() ': 0.16;
'subject:proper': 0.16; 'subject:try': 0.16; 'wrote:': 0.16;
'problem': 0.16; 'reached': 0.17; 'to:addr:python-list': 0.20;
'exception': 0.22; 'code': 0.23; 'seems': 0.26; 'thinking': 0.28;
'wrong': 0.28; 'am,': 0.31; "doesn't": 0.32; 'sep': 0.32; 'but':
0.32; 'header:In-Reply-To:1': 0.34; 'case.': 0.40; 'something':
0.40; 'should': 0.40; "there's": 0.61; 'me.': 0.62;
'received:212': 0.62; 'everything': 0.63; 'transaction': 0.64;
'your': 0.64; 'back': 0.67; 'matter': 0.68; '....': 0.76;
'exceptions': 0.84; 'handled': 0.84; 'subject:within': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net;
s=s31663417; t=1725794017; x=1726398817; i=karsten.hilbert@gmx.net;
bh=pzWfQV3m3tpEO36Tt+SUnJXJj1+EUjOYYk557jG9liQ=;
h=X-UI-Sender-Class:Date:From:To:Subject:Message-ID:References:
MIME-Version:Content-Type:In-Reply-To:Content-Transfer-Encoding:
cc:content-transfer-encoding:content-type:date:from:message-id:
mime-version:reply-to:subject:to;
b=t+xxQnGL1Qki4TQcQElXJp3cNZBgqnoey5sPZVMP8xocdDST2B3J6iqYwxR8iYD+
Q7d5m61FAk7WMs4GCyID5kB+TkC33dBK+v3SQLpxvZYfccNOUpUrxEquanec1wP+y
0TMtu2CIFKzFIUQDkX87JvpVszyLLwYI5nmAOmfDoM1TunGr/Bf8zHz7PkXU56gxc
pZpJuQQelYgImVusNA/kZf7sByIqpqKEtR5rMWtBWTKfwuaiNvTjMz5ogQqyk44YH
ZCiOJvfJJym3S5OZ6lHy5Kr0+ME5EuMisTmRiptoJAdMTyjr3dmBvfQ2Cw1Ekulmt
NAtnJL91pF9uhN5dJQ==
X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a
Content-Disposition: inline
In-Reply-To: <lk4ajkFbbnrU1@mid.individual.net>
Ma_X_il-Followup-to: d
Re_X_turn-receipt-to: Karsten.Hilbert@gmx.net
Di_X_sposition-Notification-To: Karsten.Hilbert@gmx.net
X-Confi_X_rm-Reading-To: Karsten.Hilbert@gmx.net
X-Pri_X_ority: 2 (High)
X-Provags-ID: V03:K1:9iAgHzHLHbiAL7ME3rN5jV8rUrxyGs9NC5N8YeoFe24uQ+pFmOH
rQzsYXHMQRdPKhQIhIymLpzQtZpfqQhxXApmWgVX95HvfJyY5D6Mxg2KJvoNOdbAEc14mid
QouTbBA87wEOF7LbNSNzKXc5wU8bL1VCXZltYf6sZwPPlx0Mlk2lo9ZwqBRy6rhsxLKuFjS
PyTVJcHJWoqYwYbfdfDZA==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:zSdovzJbhog=;X+2TY6ZH3XEZ5NjhUtRkRWfhFcE
Q88swJdHy8ZazOpbQNzH4NJL2dkVxNeLSWVGIfj/w3eK+V/KC7rkXonJH91uAh4iBb1Lz8XFt
TkXgKKRPe+zXWtwbtZB+OZVC5clx+6U+u9AWMa6Fv6nB2pKi5kY34gnyKL5bYnjsEsC1tzW1v
JisERndwkSFdCU7ZwtRUgC6mZekYCr4IbjbCTEo/cRg9znzQXes7aWInHQjPMWJAQrsex8Kn3
5QKDqv6gBSD1CGdnXORA3wLvgyBN9FzMY1LdA8ngWQIrjytIMyvk6BafBXXpzF+W/e24cXyaI
zC7Uze6NA7GN/HViJ6GXCpxDSpyXyKNl8O4lvXSOs/D6P63ciw+NV4DliK/zq5VZw7oWGA5Rz
iKTlDIexienaYsx3uIjZbPPeWwH0v7hsbLWp3gLaKxN7oyoNoAXQ3Z5vZA02xQj7SKLBLbRZ9
gvlblydlgvy+XMfS/uK7QnzXqAEUdEdIfbXZJxXdqfCPg5TmdGHExEseBMBZc6F7Qjbb+70zD
xWAT27GEEebBEQztX8fzyJpvIC2+p6VnxRPXiOP0B2L0qtOjyvcZmUSpPJ2NuHNpJJW5q6LtK
DJxDAHocKEdTkJjnfEu2IqWKj87+mITnFgfmWpIpkOH88oiYgasRrEo2A2jkiRrkQHjfzPNRg
emB8KPVOycI7jUqZvjyiDjkIl+Ygn+bsgoOrbWP0M1lQ9TuJOA8TXtnHhVzZanujFWi35HNVr
xG2t0PHMhZSuivy5PMsL0+v0CrsJeH0clvMV8YXzAkQcYV7WQKzVEOLBsN/izqZfoUPJhikDe
MfhDM35F6hfO6f32yr1A48Xg==
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <Zt2G4e7cwTbP3K_b@hermes.hilbert.loc>
X-Mailman-Original-References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
View all headers

Am Sun, Sep 08, 2024 at 12:48:50PM +1200 schrieb Greg Ewing via Python-list:

> On 8/09/24 9:20 am, Karsten Hilbert wrote:
> > try:
> > do something
> > except:
> > log something
> > finally:
> > .commit()
> >
> >cadence is fairly Pythonic and elegant in that it ensures the
> >the .commit() will always be reached regardless of exceptions
> >being thrown or not and them being handled or not.
>
> That seems wrong to me. I would have thought the commit should only
> be attempted if everything went right.

It is only attempted when "everything" went right. The fault
in my thinking was what the "everything" might encompass.
When some SQL fails it won't matter whether I say
conn.commit() or conn.rollback() or, in fact, nothing at all
-- the (DB !) transaction will be rolled back in any case.

However, that reasoning missed this:

> What if there's a problem in your code that causes a non-SQL-related
> exception when some but not all of the SQL statements in the
> transaction bave been [-- even successfully --] issued?

Still, in this code pattern:

> try:
> do something
> .commit()
> except:
> log something
it doesn't technically matter whether I say .commit or .rollback here:
> .rollback()

.... but ...

> Doing an explicit rollback ensures that the transaction is always
> rolled back if it is interrupted for any reason.

explicit is better than implicit ;-)

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

Subject: Re: psycopg2: proper positioning of .commit() within try: except: blocks
From: Stefan Ram
Newsgroups: comp.lang.python
Organization: Stefan Ram
Date: Sun, 8 Sep 2024 11:57 UTC
References: 1 2 3 4 5 6 7 8 9 10
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: psycopg2: proper positioning of .commit() within try: except: blocks
Date: 8 Sep 2024 11:57:45 GMT
Organization: Stefan Ram
Lines: 9
Expires: 1 Jul 2025 11:59:58 GMT
Message-ID: <rollback-20240908125702@ram.dialup.fu-berlin.de>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc> <7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com> <ZtytJMhyvtExPxfF@hermes.hilbert.loc> <5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com> <Zty7ZCMwKQl4C4Id@hermes.hilbert.loc> <4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com> <ZtzDubguRDWXwV-t@hermes.hilbert.loc> <mailman.46.1725744071.2917.python-list@python.org> <lk4ajkFbbnrU1@mid.individual.net> <slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de vmYSwKozAnrCWgOAed0mQwrizAkoCf94OK69aNOQ5K/qws
Cancel-Lock: sha1:Ax0+vnUmpAbyrXd9RxRxCXH5M4s= sha256:Hggre8fj/mBOwYkW6i5wmf0KIOVLDTDiXB7biFKYZKQ=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
View all headers

Jon Ribbens <jon+usenet@unequivocal.eu> wrote or quoted:
>What if there's an exception in your exception handler? I'd put the
>rollback in the 'finally' handler, so it's always called.

To make this happen, you'd better kick off with the rollback right
at the beginning of the "finally:" block. Otherwise, some gnarly
exception might rear its ugly head before the rollback gets called!

Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
From: Lawrence D'Oliv
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Sun, 8 Sep 2024 20:48 UTC
References: 1 2 3 4 5 6 7 8 9 10
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.python
Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List
Prohibited)
Date: Sun, 8 Sep 2024 20:48:16 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 11
Message-ID: <vbl2ig$222n3$2@dont-email.me>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 08 Sep 2024 22:48:17 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5b47ecd330ac087ccb2ea7289cdcbed3";
logging-data="2165475"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18zl6tvvQVHv2hvyCVSum/k"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:ywOOkYPPC9sIqp1/0lYTiZbXN5g=
View all headers

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.

Subject: Re: psycopg2: proper positioning of .commit() within try: except: blocks
From: Greg Ewing
Newsgroups: comp.lang.python
Date: Mon, 9 Sep 2024 01:33 UTC
References: 1 2 3 4 5 6 7 8 9 10
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: greg.ewing@canterbury.ac.nz (Greg Ewing)
Newsgroups: comp.lang.python
Subject: Re: psycopg2: proper positioning of .commit() within try: except:
blocks
Date: Mon, 9 Sep 2024 13:33:24 +1200
Lines: 16
Message-ID: <lk71j4Fnv29U1@mid.individual.net>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: individual.net WKEYURky4C1G+tW7oCtrRwRxBxbRB/FeXtRBiF93T2gSbZM622
Cancel-Lock: sha1:4wdtAiAk/XmySvhpwIrQS2u9/Lw= sha256:eOkXYV98ly2XvU+NC0NvSC2Hr96IIZUrIcNvqBX6FUU=
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:91.0)
Gecko/20100101 Thunderbird/91.3.2
Content-Language: en-US
In-Reply-To: <slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
View all headers

On 8/09/24 11:03 pm, Jon Ribbens wrote:
> On 2024-09-08, Greg Ewing <greg.ewing@canterbury.ac.nz> wrote:
>> try:
>> do something
>> .commit()
>> except:
>> log something
>> .rollback()
>
> What if there's an exception in your exception handler? I'd put the
> rollback in the 'finally' handler, so it's always called.

Good point. Putting the rollback first would be safer/

--
Greg

Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
From: Jon Ribbens
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Mon, 9 Sep 2024 09:13 UTC
References: 1 2 3 4 5 6 7 8 9 10 11
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jon+usenet@unequivocal.eu (Jon Ribbens)
Newsgroups: comp.lang.python
Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List
Prohibited)
Date: Mon, 9 Sep 2024 09:13:40 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
Injection-Date: Mon, 09 Sep 2024 11:13:41 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="91f25785d594f1a8b1e061ab48225c7b";
logging-data="2476348"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/DwbA8DF+G8sId2YuTMoVR9bB8EFX7GQc="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:o6rL9ug+WM5MP+w4mvUkWgmbNs4=
View all headers

On 2024-09-08, Lawrence D'Oliveiro <ldo@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?

Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
From: Lawrence D'Oliv
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Mon, 9 Sep 2024 09:51 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.python
Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List
Prohibited)
Date: Mon, 9 Sep 2024 09:51:02 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <vbmge5$2c7jr$1@dont-email.me>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
<slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 09 Sep 2024 11:51:02 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="48619980776be9ad3edbc43d1fdbfd55";
logging-data="2498171"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/yXGq6REX/7g2VfG1eJunA"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:jPBsOM/A9eEax6lv69U6Kf6OXcg=
View all headers

On Mon, 9 Sep 2024 09:13:40 -0000 (UTC), Jon Ribbens wrote:

> On 2024-09-08, Lawrence D'Oliveiro <ldo@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?

The database only needs to commit when it is explicitly told. Anything
less -- no commit.

Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
From: Jon Ribbens
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Mon, 9 Sep 2024 10:00 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12 13
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jon+usenet@unequivocal.eu (Jon Ribbens)
Newsgroups: comp.lang.python
Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List
Prohibited)
Date: Mon, 9 Sep 2024 10:00:11 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
<slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
<vbmge5$2c7jr$1@dont-email.me>
Injection-Date: Mon, 09 Sep 2024 12:00:11 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="91f25785d594f1a8b1e061ab48225c7b";
logging-data="2476348"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18uq8X2xb9wpUp6wWGVv06/B4M8PYkMdkw="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:ensDEUwXDHcUR/rlD/fQjAbSV3Q=
View all headers

On 2024-09-09, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
> On Mon, 9 Sep 2024 09:13:40 -0000 (UTC), Jon Ribbens wrote:
>> On 2024-09-08, Lawrence D'Oliveiro <ldo@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?
>
> 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, and is re-used
by another thread which continues using it to perform a different
sequence of operations ... ending in a COMMIT, which commits
one-and-a-half transactions.

Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
From: Karsten Hilbert
Newsgroups: comp.lang.python
Date: Mon, 9 Sep 2024 17:28 UTC
References: 1 2 3 4 5 6 7 8 9 10 11
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: Karsten.Hilbert@gmx.net (Karsten Hilbert)
Newsgroups: comp.lang.python
Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List
Prohibited)
Date: Mon, 9 Sep 2024 19:28:23 +0200
Lines: 23
Sender: <karsten.hilbert@gmx.net>
Message-ID: <mailman.2.1725902905.31645.python-list@python.org>
References: <Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
<slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
<vbmge5$2c7jr$1@dont-email.me>
<slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
<Zt8wN6CjIF8A-9d2@hermes.hilbert.loc>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de /pFRVUewYLpbdH7Ri300TgsDxYOdVGn3sd0iFi5+S0kA==
Cancel-Lock: sha1:JILsCKGQI1qq07c+9KZYGAglkaY= sha256:B2FLKpxxCgc242VYLWrSWaUWL2dBP0GkE3RTgrBOBfE=
Return-Path: <karsten.hilbert@gmx.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmx.net header.i=karsten.hilbert@gmx.net
header.b=Va0ZPRU4; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.018
X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'salt': 0.04; 'thread':
0.05; 'explicitly': 0.07; 'received:212.227': 0.07; 'cases.':
0.09; 'gpg': 0.09; 'karsten': 0.09; 'schrieb': 0.09;
'subject:Python': 0.12; '1713': 0.16; '2024': 0.16; 'commit':
0.16; 'connection.': 0.16; 'pool': 0.16; 'received:212.227.15':
0.16; 'writable': 0.16; 'python': 0.16; 'to:addr:python-list':
0.20; 'exception': 0.22; 'returns': 0.22; 'code': 0.23;
'anything': 0.25; 'perform': 0.26; 'execution': 0.32; 'right,':
0.32; 'sep': 0.32; 'unless': 0.32; 'but': 0.32; 'header:In-Reply-
To:1': 0.34; 'pending': 0.35; 'mon,': 0.36; 'using': 0.37; 'to.':
0.39; 'should': 0.40; 'connection': 0.61; 'skip:o 10': 0.61;
'received:212': 0.62; 'received:91': 0.62; 'true': 0.63;
'transaction': 0.64; 'less': 0.65; 'back': 0.67; 'operations':
0.68; 'sequence': 0.69; 'subject:List': 0.71; 'potentially': 0.76;
'database': 0.80; 'jon': 0.84; 'subject: \n ': 0.84;
'subject:Posting': 0.84; 'transactions': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net;
s=s31663417; t=1725902903; x=1726507703; i=karsten.hilbert@gmx.net;
bh=uNyKN4Kcj0rk6v1Pv8LMwz/KQ7xWWZuzqkdvxeoiBBI=;
h=X-UI-Sender-Class:Date:From:To:Subject:Message-ID:References:
MIME-Version:Content-Type:In-Reply-To:Content-Transfer-Encoding:
cc:content-transfer-encoding:content-type:date:from:message-id:
mime-version:reply-to:subject:to;
b=Va0ZPRU4oQ3yNglIWPdZRYSVWF0mc1LW0m+Zgh+EbeCzmbWXMGmeirCQ05ertarL
WCE9aHhPt+rjvSdygEqdLJgHF36hcS/jJ/EY6DvO4ogjxYaeOWNFUPgJagSWqfTLS
1vfRwWK3UMx5DWTaNZw+KfhMmXGL7W2iO+ia7Nw+ORZCCAprmb3oZsKsGUMV8FF5G
a8PTa6xum3NMo3UKyba2TplnpgERY+1CfduMTfJyIOfg/zJ8VtETvuJcxPfvU7Jbv
WMBW7SFMwS+tjxlnZ3ym9gmZrmTPvWNXuYpOGVY5WB7kuApFBBZPyyQuJ4Jxk2pHq
pPBlw79fPuwurjNL1w==
X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a
Content-Disposition: inline
In-Reply-To: <slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
Ma_X_il-Followup-to: d
Re_X_turn-receipt-to: Karsten.Hilbert@gmx.net
Di_X_sposition-Notification-To: Karsten.Hilbert@gmx.net
X-Confi_X_rm-Reading-To: Karsten.Hilbert@gmx.net
X-Pri_X_ority: 2 (High)
X-Provags-ID: V03:K1:zyigGRiVikJ+iRzhIbri4MdHaWtZW/I3jnZoldz+chDO933E6HX
ynO33PySaR39ot5rwN5Sb7287T/tlsT/jmaXko+Rt4Lzik25a3kFKTrEBXSJS42SVHPI3fc
NmgQgjgTsqGCXUE7C5DHqVmBj/szXCOTB+PIeUeT4EWpYHD+PV94vD1dGyIxEYw6iUIoE7f
2e+58Co4PUfh8DuNoOykA==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:o2DGJEsi3O0=;kWbXCO5vIQIFjyBL/BzggxHscph
A+v/kdyPoz9dnfoHGqruvHcecUX9U2y0BpypomY1hfIIhHtaFop4bMaxcLm7zG4iHAzwS5Kg2
zxqAlXZnnZwtALQlt+GG9FUOdMfowuhNy9TybfwuOlF8IWXV3Fq+4Sovbd26dlaDCdbtcEgDs
UF+mbHELnrU6po7p5hqH6ezrQGx/dItUhYFYm4f94n3qJU1qr4G6JAN6LGppFAMdtEKzr8ugQ
n3r4UYuk9oeZk4uT2B5LXhszZUa/n8bt5Ixlev+NAFtFQZ/NkziRof8bTfv377uXJlyCBPtGs
O8+YAYU5tIUUjUCOuh5FGoiTlwRj5DQjNomu6YjPrS49COUhsCcc33VuSTe5pLM88zEYdwQ4i
DGdyKK+d78plp/YqmgTZTGY37XL/4yqUlpv2JU+SZryyXpGEejIYScVtp7iTjURie/PQRvPMN
DjsVassxwMWCQc3wlkIlv5ghpcBtxasCpzaPicRTQJUgz0ZpLT2zdwlrbYIAm/oGvOlxCElKQ
TdkzI0naEZa6S/yk4El55fdH9P7Ro7lCjBcGG5g8kKxtSX93XzACqMgbmJN8bzSrEVoG9DsPv
SkKfHL3FHiGDE5l40rxFSO+zwqdcGGS+M7Fa3E326KclCCRQqkLIXajwN7YHbG3l5G9/yLZjj
8YkBvPw5zobbVMDsAY25SmbjY5PVRlmVsm4BlxpPm82Xa/DkKzKf30cT7CCLciMd+qyPuDXPg
AN3x3z8CDwldqcZ+A+QvdXhTfysac2r7sYK8/XVyV30IQqX+fOyE5C5sImnyaXEhohxLcVX34
BWF9dvEUEi3Yzto2/k5YVuWw==
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <Zt8wN6CjIF8A-9d2@hermes.hilbert.loc>
X-Mailman-Original-References: <Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
<slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
<vbmge5$2c7jr$1@dont-email.me>
<slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
View all headers

Am Mon, Sep 09, 2024 at 10:00:11AM -0000 schrieb Jon Ribbens via Python-list:

> > 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, and is re-used
> by another thread which continues using it to perform a different
> sequence of operations ... ending in a COMMIT, which commits
> one-and-a-half transactions.

Right, but that's true only when writable connections are
being pooled, which should be avoidable in many cases.

Any pool worth its salt should rollback any potentially
pending transactions of a connection when it is given back
that pooled connection. Unless explicitely told not to.

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

Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
From: Karsten Hilbert
Newsgroups: comp.lang.python
Date: Mon, 9 Sep 2024 17:29 UTC
References: 1 2 3 4 5 6 7 8 9 10 11
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: Karsten.Hilbert@gmx.net (Karsten Hilbert)
Newsgroups: comp.lang.python
Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List
Prohibited)
Date: Mon, 9 Sep 2024 19:29:27 +0200
Lines: 12
Sender: <karsten.hilbert@gmx.net>
Message-ID: <mailman.3.1725902969.31645.python-list@python.org>
References: <Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
<slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
<vbmge5$2c7jr$1@dont-email.me>
<slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
<Zt8wd9ltA1hhU9F-@hermes.hilbert.loc>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de erFIj2HbTIHERKk/e1CxeAf9Ewo+l19Qid9APieN7syg==
Cancel-Lock: sha1:7hDtVF1XZhiJ4I++Rx0/NGgjB/Q= sha256:/0h+9jfVjw14rXuJiIwd9nlZjvNs7BzVixig5Ui2rs8=
Return-Path: <karsten.hilbert@gmx.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmx.net header.i=karsten.hilbert@gmx.net
header.b=TdSmvW6D; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.031
X-Spam-Evidence: '*H*': 0.95; '*S*': 0.01; 'thread': 0.05;
'received:212.227': 0.07; 'gpg': 0.09; 'karsten': 0.09; 'schrieb':
0.09; 'subject:Python': 0.12; '1713': 0.16; '2024': 0.16; 'pool':
0.16; 'python': 0.16; 'to:addr:python-list': 0.20; 'exception':
0.22; 'returns': 0.22; 'code': 0.23; 'execution': 0.32; 'sep':
0.32; 'header:In-Reply-To:1': 0.34; 'mon,': 0.36; 'connection':
0.61; 'received:212': 0.62; 'received:91': 0.62; 'transaction':
0.64; 'subject:List': 0.71; 'database': 0.80; 'jon': 0.84;
'subject: \n ': 0.84; 'subject:Posting': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net;
s=s31663417; t=1725902967; x=1726507767; i=karsten.hilbert@gmx.net;
bh=mazSFoRhVcBIl0Ip/kC9IHYlj1FZXmgLjh0zU6HAJVA=;
h=X-UI-Sender-Class:Date:From:To:Subject:Message-ID:References:
MIME-Version:Content-Type:In-Reply-To:Content-Transfer-Encoding:
cc:content-transfer-encoding:content-type:date:from:message-id:
mime-version:reply-to:subject:to;
b=TdSmvW6DeAGjTN9UYDQ2sfLXHWdhkYYv1jdUxpOfFMKUHBylmOJ+1S04fR3Nz0Qv
hYH3duQqVZWgszOhtOmeh5S+jwk5ulYBQ3mxqnVehI+TmrTlxo+JOw+QBY3lSX2Fq
HVaK/G2xCr63E+WvAu5aipYj8JjI6+e6RYN4/uU4H5wPFEdN3khxTFRplnuTbRvb2
GsvVhlBtU+YuXZKQItaTULjLNqskSluqRd70FuFp/kDT63ef8uaSlj/KoYSET/55D
G0Gno0z8GW3Pma0cK9EG0fUJCw+8+KZNqnlyXmkEqkgvaQbhQdbkPuToZEBHi0J0i
XPCYOF6UQdyg2h3ygQ==
X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a
Content-Disposition: inline
In-Reply-To: <slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
Ma_X_il-Followup-to: d
Re_X_turn-receipt-to: Karsten.Hilbert@gmx.net
Di_X_sposition-Notification-To: Karsten.Hilbert@gmx.net
X-Confi_X_rm-Reading-To: Karsten.Hilbert@gmx.net
X-Pri_X_ority: 2 (High)
X-Provags-ID: V03:K1:iMfjhIe4agvphxYgxHeY85UcB75JBurL+Jofyw8tPFtpY+oC3nA
1Ufq07BqUZr04fOUxKlqdpU2zmmBBXjcUxzI1/dRsJ7BtZ+LrOdE15sDNb6VxR5fumUJKOs
qLaJvlUnKtIY0eKbteC9Yt6aCkCxhC8fbE9bCKSRmAdBCp6++3+80E0gwedoy5Q8nepi8au
rEs/zVJBVbBZ+rHZpwAFQ==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:xUTL3WnGMNs=;c88n+mGSiBJzZQUmVUg8Qj7sXQn
d0G2B8jjR4GeTAKFTXL4zdDnykMM845yJhgfiVh8y4H4lD3i2BfRmZ+E3NIU7momedqb4R2jS
z0tKWLlpRSDx/rLjZN2MYOFjwsQzAvu8P9QG7jlx3OzQc6Ylv423zTmLzlruXyYDFom5j8uHn
PiRSGag86K9kkssHBnl6vVOJefgV+//tTTEgy+s8yrbDK3MiPtZUNtgUZ9rdVD65ZCO4W7VKJ
qyIQoJoXoYgXCf/4yG8EFZgllERlTGS/Di+u1K9rgR+lU6pbaSRhiJnEBMsV+GlCi3+/DfgbH
5jaNBaYDhhaUaqYbIFqH99tgjG329hW36a+Surxb5TQj3itVLZ4iM1HrLnkhJ5VUegw2P0oc+
ikyKSwSlH5Cm0PoRzX5/jCDtxnt8jyjHKcSgxd3IF+Pk03/NtmotHc1hQujjmzsFXzyPdhNCL
Y8FsUaz2AoZzKBiA8QZdDHgDd829mYhPTRHl1xUx2ocjRnXHgZFWMMcqeIbZh8vipDOkV4A3M
UwnjI0xgvax8Cwjda+kionUyZw+jtL6NQwUkHQKSaCc0V8f6l1/Bxrid5VXmTkoXeVysUJjTt
lVfzhEKAAxO/dNYdTa8XhlnY9Rji1zjvQLV/VXJ7JwN8V+0644wOlC/bRkfYZbyOHBTylUsnz
AD1b64Z7l2TDgGhNZFpefvoQm7C4Tawjxm+oO1bNdVF0ZGPIQU+Tcy0JNvMB50GX+AiClTRmR
w/WQ9SXeUmwusrSTvA32ZIsUYzljzayJSGmKLHGLp3dyHCy0V6s7s3bb0y2+lyLTNX1Vtu6KM
QV9z9Gb104CgtmMUQx1IV+EQ==
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <Zt8wd9ltA1hhU9F-@hermes.hilbert.loc>
X-Mailman-Original-References: <Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
<slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
<vbmge5$2c7jr$1@dont-email.me>
<slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
View all headers

Am Mon, Sep 09, 2024 at 10:00:11AM -0000 schrieb Jon Ribbens via Python-list:

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

How does it return to the pool ?

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

Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
From: Jon Ribbens
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Mon, 9 Sep 2024 19:00 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jon+usenet@unequivocal.eu (Jon Ribbens)
Newsgroups: comp.lang.python
Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List
Prohibited)
Date: Mon, 9 Sep 2024 19:00:17 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 10
Message-ID: <slrnvduhe0.4dt.jon+usenet@raven.unequivocal.eu>
References: <Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
<slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
<vbmge5$2c7jr$1@dont-email.me>
<slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
<Zt8wd9ltA1hhU9F-@hermes.hilbert.loc>
<mailman.3.1725902969.31645.python-list@python.org>
Injection-Date: Mon, 09 Sep 2024 21:00:17 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="91f25785d594f1a8b1e061ab48225c7b";
logging-data="2653044"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1924YxPTco6W4KFvYt7i8HNvfLfXH+m3dE="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:Vs16XiFzWWm026K2avF5dyuFN2o=
View all headers

On 2024-09-09, Karsten Hilbert <Karsten.Hilbert@gmx.net> wrote:
> Am Mon, Sep 09, 2024 at 10:00:11AM -0000 schrieb Jon Ribbens via Python-list:
>> 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,
>
> How does it return to the pool ?

It's just any circumstance in which a bit of your code uses a database
"cursor" (which isn't a cursor) that it didn't create moments before.

Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
From: Lawrence D'Oliv
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Mon, 9 Sep 2024 21:05 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.python
Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List
Prohibited)
Date: Mon, 9 Sep 2024 21:05:34 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 18
Message-ID: <vbnnuu$2i1cc$1@dont-email.me>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
<slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
<vbmge5$2c7jr$1@dont-email.me>
<slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 09 Sep 2024 23:05:35 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="48619980776be9ad3edbc43d1fdbfd55";
logging-data="2688396"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/sdx9C0ad3HDuaWAzm5Z7c"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:vNYiAfKv99H0CIGEt4veMzZPRtw=
View all headers

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.

Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
From: Jon Ribbens
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Mon, 9 Sep 2024 21:12 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jon+usenet@unequivocal.eu (Jon Ribbens)
Newsgroups: comp.lang.python
Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List
Prohibited)
Date: Mon, 9 Sep 2024 21:12:51 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <slrnvdup6j.4dt.jon+usenet@raven.unequivocal.eu>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
<slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
<vbmge5$2c7jr$1@dont-email.me>
<slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
<vbnnuu$2i1cc$1@dont-email.me>
Injection-Date: Mon, 09 Sep 2024 23:12:51 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="91f25785d594f1a8b1e061ab48225c7b";
logging-data="2664131"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+rMS5k9s+RHODrXntVThvP7ad1sEk8UZ8="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:CN2U796v4soSyEOlk9UauK5p6bY=
View all headers

On 2024-09-09, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
> 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.

How does that happen then?

Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
From: Lawrence D'Oliv
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Mon, 9 Sep 2024 21:16 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.python
Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List
Prohibited)
Date: Mon, 9 Sep 2024 21:16:09 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <vbnoio$2i1cc$6@dont-email.me>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
<slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
<vbmge5$2c7jr$1@dont-email.me>
<slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
<vbnnuu$2i1cc$1@dont-email.me>
<slrnvdup6j.4dt.jon+usenet@raven.unequivocal.eu>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 09 Sep 2024 23:16:09 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="48619980776be9ad3edbc43d1fdbfd55";
logging-data="2688396"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19nGnKeQoUIxCGfsQJFwGI2"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:JGP+1dIhV52N/P1FUAnABTe8tnc=
View all headers

On Mon, 9 Sep 2024 21:12:51 -0000 (UTC), Jon Ribbens wrote:

> On 2024-09-09, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>
>> 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.
>
> How does that happen then?

You write code to do it.

Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
From: Jon Ribbens
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Tue, 10 Sep 2024 08:38 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jon+usenet@unequivocal.eu (Jon Ribbens)
Newsgroups: comp.lang.python
Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List
Prohibited)
Date: Tue, 10 Sep 2024 08:38:30 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <slrnve01c6.4dt.jon+usenet@raven.unequivocal.eu>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
<slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
<vbmge5$2c7jr$1@dont-email.me>
<slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
<vbnnuu$2i1cc$1@dont-email.me>
<slrnvdup6j.4dt.jon+usenet@raven.unequivocal.eu>
<vbnoio$2i1cc$6@dont-email.me>
Injection-Date: Tue, 10 Sep 2024 10:38:30 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="b30a0956c5fda07dde43fc5014b8f1ec";
logging-data="3025543"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+lDLgu092ijGPkch+q5KvVq0curY/+eAk="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:1zUCNGN4HUuL6apolfBpaDSuyc8=
View all headers

On 2024-09-09, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
> On Mon, 9 Sep 2024 21:12:51 -0000 (UTC), Jon Ribbens wrote:
>> On 2024-09-09, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>> 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.
>>
>> How does that happen then?
>
> You write code to do it.

Ok. So we've moved away from "In any DBMS worth its salt, rollback is
something that happens automatically" and now you're saying it isn't
automatic after all, "you write code to do it". That was my point.
The database provides the tools, but it isn't psychic.

Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
From: Karsten Hilbert
Newsgroups: comp.lang.python
Date: Tue, 10 Sep 2024 15:56 UTC
References: 1 2 3 4 5 6 7 8 9 10 11
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: Karsten.Hilbert@gmx.net (Karsten Hilbert)
Newsgroups: comp.lang.python
Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List
Prohibited)
Date: Tue, 10 Sep 2024 17:56:24 +0200
Lines: 16
Sender: <karsten.hilbert@gmx.net>
Message-ID: <mailman.4.1725983782.31645.python-list@python.org>
References: <lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
<slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
<vbmge5$2c7jr$1@dont-email.me>
<slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
<vbnnuu$2i1cc$1@dont-email.me>
<slrnvdup6j.4dt.jon+usenet@raven.unequivocal.eu>
<vbnoio$2i1cc$6@dont-email.me>
<slrnve01c6.4dt.jon+usenet@raven.unequivocal.eu>
<ZuBsKKKHUH6OreGT@hermes.hilbert.loc>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de G4fY6e+WBuaRlDbc7PpdVgTqi22mnVnS6fjfqF0omRiQ==
Cancel-Lock: sha1:L0//cbEhz/c/bUEwSuPZRCyD4N0= sha256:BMGKLOGp7I5G+Wh1jOBHRSZfnh+FTFyZ72JhIpDXpHI=
Return-Path: <karsten.hilbert@gmx.net>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmx.net header.i=karsten.hilbert@gmx.net
header.b=OVti2nHx; dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.025
X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'received:212.227': 0.07;
'gpg': 0.09; 'karsten': 0.09; 'moved': 0.09; 'schrieb': 0.09;
'subject:Python': 0.12; '"in': 0.16; '1713': 0.16; '2024': 0.16;
'ok.': 0.16; 'received:212.227.15': 0.16; 'tue,': 0.19; 'to:addr
:python-list': 0.20; 'all,': 0.20; 'saying': 0.25; 'again,': 0.26;
'brought': 0.26; "isn't": 0.27; 'asked': 0.29; 'sep': 0.32;
'header:In-Reply-To:1': 0.34; 'automatic': 0.35; "we've": 0.39;
'happen': 0.40; 'something': 0.40; '10,': 0.61; 'received:212':
0.62; 'received:91': 0.62; 'away': 0.67; 'subject:List': 0.71;
'happens': 0.84; 'jon': 0.84; 'subject: \n ': 0.84;
'subject:Posting': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.net;
s=s31663417; t=1725983780; x=1726588580; i=karsten.hilbert@gmx.net;
bh=4hhG5b85x58JOcAe5dLmSF7P2vup6xXAiKMvjnUKv9U=;
h=X-UI-Sender-Class:Date:From:To:Subject:Message-ID:References:
MIME-Version:Content-Type:In-Reply-To:Content-Transfer-Encoding:
cc:content-transfer-encoding:content-type:date:from:message-id:
mime-version:reply-to:subject:to;
b=OVti2nHxC/rMO/wyNmp2dmuqTAIv9bXvtECBU6NUp3xuyvofq1qqLUEYM42NZl1E
R574fK2iA3LmmmTf63/AW0O1ZTuaHqKO+LpWpdj0zPv7Nn6CZhpqMKtso2hNigZKW
hQep4wof55oVtUKEktqTE2+JB2hA6j2KMMDdT4zV/viYgWEnSIHQV9ODnCtvrhfsW
NxXpTdZ8o1wASCuKvu09UMDFDVWwXhwOYVtevz22s6ZXHhjSl3uja145qd9lCxfY5
To7XDYMgWMXOssdgOmZ5QkLa2wSRe9PeDS0UGCQoNpbyYFrJl/shC1e8dC8iwbFKo
jLi1k2WxgaUX2FFIuA==
X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a
Content-Disposition: inline
In-Reply-To: <slrnve01c6.4dt.jon+usenet@raven.unequivocal.eu>
Ma_X_il-Followup-to: d
Re_X_turn-receipt-to: Karsten.Hilbert@gmx.net
Di_X_sposition-Notification-To: Karsten.Hilbert@gmx.net
X-Confi_X_rm-Reading-To: Karsten.Hilbert@gmx.net
X-Pri_X_ority: 2 (High)
X-Provags-ID: V03:K1:k43+PjJTKZYY7SP2HvA3Oz6/3kYD/yR68efzC/bKbp/H+KRU/1f
i/1ZYzplY90pyLhSx+nTMeO0VAENTdWtrb6cGxaQwtya85eaxSLLfaPAzKo7uDUunEn4lGN
UXcQxGidn5JjAXSpeQwcOJtD/of9Heocf521LzggtpthVpDJvD4GQ6mOF3iIrsidogCWbMi
/ZUF1EpGfJT6z4dDNfhhQ==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:1Jesd+lGwKA=;N/kpVmr/9Vc88uEO5WYN36ENWpT
Ts5nI+DiDGoo5xDSjJoOzhNGA6s2DA+tdMRjepkqGa0sUqRbQYr9AkNUKLViWlgu21rnTr2nO
DLQKLJY1n/fdZcQAP4WFZC2K8jpm5VbX/lEKTRvVUzjTIuQsO9sDZ6yP3PtVwgHnEK0iwIfpd
27r2AXXjYhsPHDDbKjfKsI51R2+BN+DvCWj+jHIy5wD/N3+iYFlTdTjd+mEC6g2I6d0JZmRj4
eceVIWEp8ZMcXDtByZC1rhANnJcWe9idba7qztG89OAoW4JB944UM2HsrDZYCKEq1cyEunsgZ
oh+5c+LPQxlsv3p/M0ZEIXgqsgmO1L6nkgu9kCnw7CwStfAn2t6uL1XUeB0/s5DJDXEbT3vyh
Tw45F4NAybnKSmXluHUq26FK3Jhk+NBYXVPP1GWsMQ1Bn5HXBE5XpXeFj57AsEMmH2PfJCKU1
85OsVjxGuQlbSnYzJiOv11zsy2VRObJeXbglYibpqYrlRqBokxEFbHO5kJzVPAtIofRhKR3ZK
saIXk5+41ZytyQkgC0y0ou+RlCq63XIV+HC4OkajXvXSUOhLq21JYJyY83riMCOdfahAfSYWE
mZNbpfYlugleuKtw25iPpgHYQ5EDi0S3Ojn2KDY/cU7+yRMD2Px4pY0/YMp1CumVw6V1wo3/F
cftTQ7YdAdX+/9tYxtmmwcKxeNwFvXeeZzyCmXuZPM2UdumJFOdk5nkBn1T9vXd5UeUzXK8Er
RV9xkxxWafgD+3Rm2m+wux6LKhVR0KyZmxsIBSRBqRl65+Ms0EL7dWHcipUomLrJSKm1ozLmQ
5si8TDt4JOh5oR5SaN2sdt9Q==
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <ZuBsKKKHUH6OreGT@hermes.hilbert.loc>
X-Mailman-Original-References: <lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
<slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
<vbmge5$2c7jr$1@dont-email.me>
<slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
<vbnnuu$2i1cc$1@dont-email.me>
<slrnvdup6j.4dt.jon+usenet@raven.unequivocal.eu>
<vbnoio$2i1cc$6@dont-email.me>
<slrnve01c6.4dt.jon+usenet@raven.unequivocal.eu>
View all headers

Am Tue, Sep 10, 2024 at 08:38:30AM -0000 schrieb Jon Ribbens via Python-list:

> Ok. So we've moved away from "In any DBMS worth its salt, rollback is
> something that happens automatically"

Nope. The original post asked something entirely different.

> and now you're saying it isn't automatic after all,

No again, such shenanigans only start to happen when pooling
is brought into the equation.

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

Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
From: Jon Ribbens
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Tue, 10 Sep 2024 16:20 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jon+usenet@unequivocal.eu (Jon Ribbens)
Newsgroups: comp.lang.python
Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List
Prohibited)
Date: Tue, 10 Sep 2024 16:20:22 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <slrnve0se6.4dt.jon+usenet@raven.unequivocal.eu>
References: <lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
<slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
<vbmge5$2c7jr$1@dont-email.me>
<slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
<vbnnuu$2i1cc$1@dont-email.me>
<slrnvdup6j.4dt.jon+usenet@raven.unequivocal.eu>
<vbnoio$2i1cc$6@dont-email.me>
<slrnve01c6.4dt.jon+usenet@raven.unequivocal.eu>
<ZuBsKKKHUH6OreGT@hermes.hilbert.loc>
<mailman.4.1725983782.31645.python-list@python.org>
Injection-Date: Tue, 10 Sep 2024 18:20:22 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="b30a0956c5fda07dde43fc5014b8f1ec";
logging-data="3183274"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WjEX31bI2HDXwR41f2FqAsqShZIEt/s0="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:BKeiEiexmA230cENZ8m/yLycxII=
View all headers

On 2024-09-10, Karsten Hilbert <Karsten.Hilbert@gmx.net> wrote:
> Am Tue, Sep 10, 2024 at 08:38:30AM -0000 schrieb Jon Ribbens via Python-list:
>> Ok. So we've moved away from "In any DBMS worth its salt, rollback is
>> something that happens automatically"
>
> Nope. The original post asked something entirely different.

No it didn't.

>> and now you're saying it isn't automatic after all,
>
> No again, such shenanigans only start to happen when pooling
> is brought into the equation.

No they don't.

Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
From: Lawrence D'Oliv
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Tue, 10 Sep 2024 20:57 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.python
Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List
Prohibited)
Date: Tue, 10 Sep 2024 20:57:38 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <vbqbs2$35fpe$2@dont-email.me>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
<slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
<vbmge5$2c7jr$1@dont-email.me>
<slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
<vbnnuu$2i1cc$1@dont-email.me>
<slrnvdup6j.4dt.jon+usenet@raven.unequivocal.eu>
<vbnoio$2i1cc$6@dont-email.me>
<slrnve01c6.4dt.jon+usenet@raven.unequivocal.eu>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 10 Sep 2024 22:57:38 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="110520bb82bb1911011964dccfc64be6";
logging-data="3325742"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+3XYzTJ/L9TZnMwEQiIi99"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:5t36A44KuMJC0yiylEbGufjryj8=
View all headers

On Tue, 10 Sep 2024 08:38:30 -0000 (UTC), Jon Ribbens wrote:

> On 2024-09-09, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>
>> On Mon, 9 Sep 2024 21:12:51 -0000 (UTC), Jon Ribbens wrote:
>>>
>>> On 2024-09-09, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>>>
>>>> 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.
>>>
>>> How does that happen then?
>>
>> You write code to do it.
>
> Ok. So we've moved away from "In any DBMS worth its salt, rollback is
> something that happens automatically" and now you're saying it isn't
> automatic after all, "you write code to do it".

The database code already performs that function. As far as the client is
concerned, the function happens automatically.

And it’s not just code, it’s data. 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.

Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
From: Jon Ribbens
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Tue, 10 Sep 2024 22:48 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jon+usenet@unequivocal.eu (Jon Ribbens)
Newsgroups: comp.lang.python
Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List
Prohibited)
Date: Tue, 10 Sep 2024 22:48:36 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <slrnve1j64.4dt.jon+usenet@raven.unequivocal.eu>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
<slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
<vbmge5$2c7jr$1@dont-email.me>
<slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
<vbnnuu$2i1cc$1@dont-email.me>
<slrnvdup6j.4dt.jon+usenet@raven.unequivocal.eu>
<vbnoio$2i1cc$6@dont-email.me>
<slrnve01c6.4dt.jon+usenet@raven.unequivocal.eu>
<vbqbs2$35fpe$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 11 Sep 2024 00:48:37 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="31e9d30ed15ab641891ce1c0fa4073b7";
logging-data="3372633"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19s0Lc0NOMFNiz1PRFDV9sunJCaBNqEqJw="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:EKTLXRPhbZL2vMkQ1kQrWaEX5dc=
View all headers

On 2024-09-10, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
> On Tue, 10 Sep 2024 08:38:30 -0000 (UTC), Jon Ribbens wrote:
>
>> On 2024-09-09, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>>
>>> On Mon, 9 Sep 2024 21:12:51 -0000 (UTC), Jon Ribbens wrote:
>>>>
>>>> On 2024-09-09, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>>>>>
>>>>> 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.
>>>>
>>>> How does that happen then?
>>>
>>> You write code to do it.
>>
>> Ok. So we've moved away from "In any DBMS worth its salt, rollback is
>> something that happens automatically" and now you're saying it isn't
>> automatic after all, "you write code to do it".
>
> The database code already performs that function. As far as the client is
> concerned, the function happens automatically.

.... but only if "you write code to do it".

> And it’s not just code, it’s data. 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.

Yes, nobody's disputing that. A good database will do what you tell it,
and keep the data you give it. But what if you tell it the wrong thing
or give it the wrong data? It's like, for example, a RAID array will
save you from a faulty disk, but will not save you from the software
writing incorrect data, which the RAID array will then faithfully copy
across to all the disks overwriting the good data.

Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
From: Lawrence D'Oliv
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Wed, 11 Sep 2024 20:30 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.python
Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List
Prohibited)
Date: Wed, 11 Sep 2024 20:30:56 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <vbsum0$3pop6$1@dont-email.me>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
<slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
<vbmge5$2c7jr$1@dont-email.me>
<slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
<vbnnuu$2i1cc$1@dont-email.me>
<slrnvdup6j.4dt.jon+usenet@raven.unequivocal.eu>
<vbnoio$2i1cc$6@dont-email.me>
<slrnve01c6.4dt.jon+usenet@raven.unequivocal.eu>
<vbqbs2$35fpe$2@dont-email.me>
<slrnve1j64.4dt.jon+usenet@raven.unequivocal.eu>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 11 Sep 2024 22:30:57 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="4818e99c43a92fda07902f52f7adfbd5";
logging-data="3990310"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19dV7e8OCGLjChKP+XNGyZY"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:xxYxbVIvP3DMkJKBdiVnrPOBCgU=
View all headers

On Tue, 10 Sep 2024 22:48:36 -0000 (UTC), Jon Ribbens wrote:

> But what if you tell it the wrong thing ...

To get back to the original point of this thread, all that rigmarole to
try to ensure to call “rollback” in case of an exception is completely
unnecessary: the DBMS will take care of that for you.

Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
From: Jon Ribbens
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Wed, 11 Sep 2024 21:12 UTC
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jon+usenet@unequivocal.eu (Jon Ribbens)
Newsgroups: comp.lang.python
Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List
Prohibited)
Date: Wed, 11 Sep 2024 21:12:01 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 9
Message-ID: <slrnve41t1.4c4.jon+usenet@raven.unequivocal.eu>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
<slrnvdr13p.4dt.jon+usenet@raven.unequivocal.eu>
<vbl2ig$222n3$2@dont-email.me>
<slrnvdtf24.4dt.jon+usenet@raven.unequivocal.eu>
<vbmge5$2c7jr$1@dont-email.me>
<slrnvdthpa.4dt.jon+usenet@raven.unequivocal.eu>
<vbnnuu$2i1cc$1@dont-email.me>
<slrnvdup6j.4dt.jon+usenet@raven.unequivocal.eu>
<vbnoio$2i1cc$6@dont-email.me>
<slrnve01c6.4dt.jon+usenet@raven.unequivocal.eu>
<vbqbs2$35fpe$2@dont-email.me>
<slrnve1j64.4dt.jon+usenet@raven.unequivocal.eu>
<vbsum0$3pop6$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 11 Sep 2024 23:12:02 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="31e9d30ed15ab641891ce1c0fa4073b7";
logging-data="4007909"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19FhOkgmQY81hos88JP4+nCokIEevBH4No="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:Z1ANiqKa0PwCRneEfSftGEymMYE=
View all headers

On 2024-09-11, Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
> On Tue, 10 Sep 2024 22:48:36 -0000 (UTC), Jon Ribbens wrote:
>> But what if you tell it the wrong thing ...
>
> To get back to the original point of this thread, all that rigmarole to
> try to ensure to call “rollback” in case of an exception is completely
> unnecessary: the DBMS will take care of that for you.

No, it won't.

Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
From: Lawrence D'Oliv
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Thu, 12 Sep 2024 23:10 UTC
References: 1 2 3 4 5 6 7 8 9
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ldo@nz.invalid (Lawrence D'Oliveiro)
Newsgroups: comp.lang.python
Subject: Re: psycopg2 positioning of .commit() (Posting On Python-List
Prohibited)
Date: Thu, 12 Sep 2024 23:10:05 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <vbvscd$fkeu$2@dont-email.me>
References: <Ztx1sZMGTnA3eLP1@hermes.hilbert.loc>
<7cb50df2-9c76-477f-91c9-e149c7637104@aklaver.com>
<ZtytJMhyvtExPxfF@hermes.hilbert.loc>
<5ee80b84-f04b-454d-ab39-45572e0751a1@aklaver.com>
<Zty7ZCMwKQl4C4Id@hermes.hilbert.loc>
<4a1b12fc-24b7-4c7e-b1f2-6ec9c5f341c2@aklaver.com>
<ZtzDubguRDWXwV-t@hermes.hilbert.loc>
<mailman.46.1725744071.2917.python-list@python.org>
<lk4ajkFbbnrU1@mid.individual.net>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 13 Sep 2024 01:10:06 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="fe8eaca0c36637cab02c0b5baab677cf";
logging-data="512478"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19S0EvOgYUaJyIQby/Fjc1j"
User-Agent: Pan/0.160 (Toresk; )
Cancel-Lock: sha1:uYgtgrAYil0pDNDCZn0xL194Fxc=
View all headers

On Sun, 8 Sep 2024 12:48:50 +1200, Greg Ewing wrote:

> This is how I normally do things like this:
>
> try:
> do something .commit()
> except:
> log something .rollback()
>
> Doing an explicit rollback ensures that the transaction is always rolled
> back if it is interrupted for any reason.

Don’t bother. Let the DBMS deal with that for you. That’s what it’s for.

Also, maybe you meant “finally” instead of “except”?

1

rocksolid light 0.9.8
clearnet tor