Michael Bayer wrote:

<-cut->

if you are looking to use a named cursor within generated SQL and/or ORM (session) flushes and stuff like that, the API is not really there for that stuff. you can create ResultProxy objects with a cursor, like this:

    connection = engine.connect()
    dbapi_conn = connection.connection
    cursor = dbapi_conn.cursor("test")
    result = cursor.execute("select * from table")
    result_proxy = ResultProxy(engine, connection, cursor, None)

but thats about as much as you can do.


Yes. it's a solution (good) for me

<-cut->

so the main question is, what do you need named cursors for ?


Because, like what I wrote on the psycopg2 ml (lists.initd.org/pipermail/psycopg/2007-January/005250.html) without the "server side cursor", the memory usage on the client side is proportionally at the number of records returned by the query (on my example 400k records, 60MB ram). I think because the driver fetch all the data from the server and leave it available with the fetchXXX methods.
With the other solution, the driver fetch it only then a request occur.
So, from here, my question born :)
As far as I can read on internet, not all the drivers can use the named cursor feature (pg and oracle yes), but I believe that when it support this feature (also mentioned on the DB-API2 spec.), why not use it?

Thanks,
Michele

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to