Sujet : Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.pythonDate : 13. Sep 2024, 00:10:05
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vbvscd$fkeu$2@dont-email.me>
References : 1 2 3 4 5 6 7 8 9
User-Agent : Pan/0.160 (Toresk; )
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”?