Named cursor problem

From: Vojtěch Rylko <rylko(at)vojtuv(dot)net>
To: psycopg(at)postgresql(dot)org
Subject: Named cursor problem
Date: 2012-01-30 16:09:15
Message-ID: 4F26C0AB.1030603@vojtuv.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

Hi,

I am using named cursor in this manner:

cursor = conn.cursor(str(os.getpid))
cursor.execute("select * from documents;")
for row in cursor: print do_something(row) # this function also creates
cursors from "conn"

One million rows have to be processed, but after 10-20 thousands
processed rows I got an error:
Traceback (most recent call last):
File "/homes/eva/xr/xrylko00/spinn/spinn3r/db/db2xml.py", line 408,
in <module>
query = query)
File "/homes/eva/xr/xrylko00/spinn/spinn3r/db/db2xml.py", line 351,
in create_xml
for item in self.get_item(column, identifiers, query):
File "/homes/eva/xr/xrylko00/spinn/spinn3r/db/db2xml.py", line 172,
in get_item
for row in cursor:
ProgrammingError: named cursor isn't valid anymore

Where may be problem?

PostgreSQL 8.4.9 on x86_64-redhat-linux-gnu, compiled by GCC gcc (GCC)
4.1.2 20080704 (Red Hat 4.1.2-51), 64-bit
Python 2.6.5 (r265:79063, Jun 22 2010, 14:35:26)
[GCC 4.3.5] on linux2
>>> import psycopg2
>>> psycopg2.__version__
'2.2.2 (dt dec ext pq3)'

Cheers,
Vojtěch R.

Responses

Browse psycopg by date

  From Date Subject
Next Message Federico Di Gregorio 2012-01-30 16:13:17 Re: Named cursor problem
Previous Message Peter Irbizon 2012-01-17 16:56:01 Re: after application close MS Visual C++ runtime library error occurs