From: | Federico Di Gregorio <fog(at)dndg(dot)it> |
---|---|
To: | thomas veymont <thomas(dot)veymont(at)gmail(dot)com> |
Cc: | psycopg(at)postgresql(dot)org |
Subject: | Re: using server side cursor |
Date: | 2011-10-14 11:41:30 |
Message-ID: | 4E981FEA.6010702@dndg.it |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
On 14/10/11 12:32, thomas veymont wrote:
[snip]
> I guess I'm doing it the wrong way. There's a doc in psycopg
> about named cursors but I don't understand exactly how I should
> follow it to tie to my problem. (that is : using my existing pgpsql function
> that returns a cursor, then iterate on that cursor).
>
> any suggestion ?
Yes, use the native support for server-side cursors in psycopg. First,
don't use a procedure to setup the cursor but just pass to execute()
your SQL:
curs = conn.cursor("mycursor")
curs.execute("SELECT col FROM test")
curs.fetchmany(10) # fetch 10 rows from the cursor
hipe this helps,
federico
--
Federico Di Gregorio fog(at)initd(dot)org
When people say things are a lot more complicated than that, they
means they're getting worried that they won't like the truth.
-- Granny Weatherwax
From | Date | Subject | |
---|---|---|---|
Next Message | Daniele Varrazzo | 2011-10-14 12:07:42 | Re: using server side cursor |
Previous Message | thomas veymont | 2011-10-14 10:32:03 | using server side cursor |