Sujet : Re: psycopg2 positioning of .commit() (Posting On Python-List Prohibited)
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.pythonDate : 09. Sep 2024, 05:34:27
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vblqc3$2987j$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11
User-Agent : Pan/0.160 (Toresk; )
On Mon, 9 Sep 2024 13:48:32 +1200, Greg Ewing wrote:
I would much prefer to have just *one* place where exceptions are caught
and logged.
Why catch exceptions at all? The only kind of database-related exception
I’ve felt the need to catch so far is the occasional IntegrityError from
trying to insert a record with a duplicate key (and that only in certain
situations). Anything else (particularly SQL syntax errors) I would rather
just leave to the default exception-handling mechanism -- why waste time
reinventing its information-reporting abilities?