On 2024-09-08, Greg Ewing 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() wil
Am Mon, Sep 09, 2024 at 01:48:32PM +1200 schrieb Greg Ewing via Python-list:
> That code doesn't inspire much confidence in me. It's far too
> convoluted with too much micro-management of exceptions.
It is catching two exceptions, re-raising both of them,
except for re-raising one of them as anot
Am Mon, Sep 09, 2024 at 01:48:32PM +1200 schrieb Greg Ewing via Python-list:
> That code doesn't inspire much confidence in me. It's far too
> convoluted with too much micro-management of exceptions.
>
> I would much prefer to have just *one* place where exceptions are
> caught and logged.
I am o
On 9/09/24 2:13 am, Karsten Hilbert wrote:
For what it's worth here's the current state of code:
That code doesn't inspire much confidence in me. It's far too
convoluted with too much micro-management of exceptions.
I would much prefer to have just *one* place where exceptions are
caught and l
On 8/09/24 11:03 pm, Jon Ribbens wrote:
On 2024-09-08, Greg Ewing 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.
Am Sun, Sep 08, 2024 at 02:58:03PM +0100 schrieb Rob Cliffe via Python-list:
> >Ugly:
> >
> > try:
> > do something
> > except:
> > log something
> > finally:
> > try:
> > .commit()
> > except:
> >
On 07/09/2024 22:20, Karsten Hilbert via Python-list wrote:
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 co
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
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
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 exception
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
Am Sat, Sep 07, 2024 at 01:03:34PM -0700 schrieb Adrian Klaver:
> In the case you show you are doing commit() before the close() so any errors
> in the
> transactions will show up then. My first thought would be to wrap the
> commit() in a
> try/except and deal with error there.
Right, and this
Am Sat, Sep 07, 2024 at 09:46:03AM -0700 schrieb Adrian Klaver:
> >unto now I had been thinking this is a wise idiom (in code
> >that needs not care whether it fails to do what it tries to
> >do^1):
> >
> > conn = psycopg2.connection(...)
>
> In the above do you have:
>
> https://www.psycopg.o
On 07/09/2024 16:48, Karsten Hilbert via Python-list wrote:
Dear all,
unto now I had been thinking this is a wise idiom (in code
that needs not care whether it fails to do what it tries to
do^1):
conn = psycopg2.connection(...)
curs = conn.cursor()
try:
c
Dear all,
unto now I had been thinking this is a wise idiom (in code
that needs not care whether it fails to do what it tries to
do^1):
conn = psycopg2.connection(...)
curs = conn.cursor()
try:
curs.execute(SOME_SQL)
except PSYCOPG2-Exception:
15 matches
Mail list logo