Re: libpq custom row processing - Mailing list psycopg

From Federico Di Gregorio
Subject Re: libpq custom row processing
Date
Msg-id 50210002.8060100@dndg.it
Whole thread Raw
In response to Re: libpq custom row processing  (Marko Kreen <markokr@gmail.com>)
Responses Re: libpq custom row processing
List psycopg
On 07/08/12 13:41, Marko Kreen wrote:
> Same thing happens when you fetch the result in transaction
> and later query fails with error thus invalidating earlier
> processing.  So nothing new.
>
> Or how about FETCH 100 from cursor in transaction,
> and first few succeed and later one fails.
>
> It's up to user code to handle such cases correctly
> and "correct" here depends on actual business logic
> of the transaction.
>
> The warning is there because there is now new
> failure scenario, but not because the failure
> needs any kind of special handling.

I don't agree. Simple code like:

curs.execute("SELECT * FROM xs")
for x in curs.fetchall():
    # do something like writing to the file system with x

will have a different effect if row-by-row processing is enabled. Before
nothing would be changed on the file system in case of error: the
fetchall() is "atomic"; while now you write to the file system until the
row that causes the error is processed.

federico

--
Federico Di Gregorio                         federico.digregorio@dndg.it
Studio Associato Di Nunzio e Di Gregorio                  http://dndg.it
 There's no greys, only white that's got grubby. I'm surprised you
  don't know that. And sin, young man, is when you treat people as
  things. Including yourself.                       -- Granny Weatherwax

psycopg by date:

Previous
From: Marko Kreen
Date:
Subject: Re: libpq custom row processing
Next
From: Marko Kreen
Date:
Subject: Re: libpq custom row processing