Thread: Named Cursors WITH HOLD
Hi, i'm using psycopg and i'm noticing that Named Cursors are being deleted by PostgreSQL whenever i do a commit. This is the default behaviour specified in [1], but there is a parameter when creating a cursor called "WITH HOLD" that allows a cursor outside any transaction. But i can't see any way in the psycopg API to do this. Maybe a cursor factory, but I've no idea on how to do it. [1]: http://www.postgresql.org/docs/current/static/sql-declare.html
On 05/07/11 09:07, deavid wrote: > Hi, i'm using psycopg and i'm noticing that Named Cursors are being > deleted by PostgreSQL whenever i do a commit. This is the default > behaviour specified in [1], but there is a parameter when creating a > cursor called "WITH HOLD" that allows a cursor outside any > transaction. > > But i can't see any way in the psycopg API to do this. Maybe a cursor > factory, but I've no idea on how to do it. WITH HOLD cursors aren't natively supported by psycopg. You can do your own cursor management, wait for someone to add this feature or add the feature yourself (it should be quite easy to add an "hold" option). federico -- Federico Di Gregorio federico.digregorio@dndg.it Studio Associato Di Nunzio e Di Gregorio http://dndg.it In some countries (e.g., Germany) even many brands of toilet paper have format A6. [http://www.cl.cam.ac.uk/~mgk25/iso-paper.html]
On 05/07/11 09:07, deavid wrote: > Hi, i'm using psycopg and i'm noticing that Named Cursors are being > deleted by PostgreSQL whenever i do a commit. This is the default > behaviour specified in [1], but there is a parameter when creating a > cursor called "WITH HOLD" that allows a cursor outside any > transaction. I first try at WITH HOLD is available from the devel branch: git://luna.dndg.it/public/psycopg2 Example code: curs = conn.cursort("NAME") curs.withhold = True curs.execute("SELECT ..."); conn.commit() curs.fetchXXX() It should work. If it doesn't work please report any bug so that we can fix them before the release. federico -- Federico Di Gregorio federico.digregorio@dndg.it Studio Associato Di Nunzio e Di Gregorio http://dndg.it The only thing I see is if you are pumping so much data into the database all the time when do you expect to look at it? -- Charlie Clark
On 05/07/11 10:29, Federico Di Gregorio wrote: > On 05/07/11 09:07, deavid wrote: >> > Hi, i'm using psycopg and i'm noticing that Named Cursors are being >> > deleted by PostgreSQL whenever i do a commit. This is the default >> > behaviour specified in [1], but there is a parameter when creating a >> > cursor called "WITH HOLD" that allows a cursor outside any >> > transaction. > I first try "I first try"? Gosh, much work and no play makes fog a dull boy. federico -- Federico Di Gregorio federico.digregorio@dndg.it Studio Associato Di Nunzio e Di Gregorio http://dndg.it Se sai che hai un ***** di file così, lo manovri subito. -- vodka