Deutsch   English   Français   Italiano  
<vbvscd$fkeu$2@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!2.eu.feeder.erje.net!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Lawrence D'Oliveiro <ldo@nz.invalid>
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=
Bytes: 1842

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”?