Re: using server side cursor

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
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 12:07:42
Message-ID: CA+mi_8YtcXc235ZC9rHz4X5tGWM2B-WurBtxo5mdA+9AcoXKgQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Fri, Oct 14, 2011 at 11:32 AM, thomas veymont
<thomas(dot)veymont(at)gmail(dot)com> wrote:

> mycursor.execute ( "fetch", [ "mycursor" ] ) # fetch row from this cursor
> mycursor.fetchone()

This is the only error you have made: there is no placeholder in the
query. And even if there was, it would be an error as it would result
in something like "fetch 'mycursor' ", and postgres doesn't want the
quotes.

mycursor.execute ( "fetch mycursor" ) would do what you were
expecting. If you have to compose the command, you have no protection
though, so you should be hypercareful about where "mycursor" comes
from.

Federico is right though that using the plain query with a psycopg
named cursor makes things easier.

-- Daniele

In response to

Browse psycopg by date

  From Date Subject
Next Message Daniele Varrazzo 2011-10-14 12:18:40 Re: using server side cursor
Previous Message Federico Di Gregorio 2011-10-14 11:41:30 Re: using server side cursor