help: pypgsql: this code works in Fedora core 1, Not in FC2

J Dubal dubal at khimjiramdas.com
Sun Sep 26 09:41:49 CEST 2004


Hello good people,

Following works in FC1 (python-2.2.3-7, postgresql-7.3.4-11,
kernel-2.4.22-1.2194.nptl, pyPgSQL-2.4)

from pyPgSQL   import PgSQL
conn  = PgSQL.connect('localhost',database='rop')
loccur  = conn.cursor()
loccur.execute("DECLARE itemcursor CURSOR FOR \
              SELECT * FROM locmf")
loccur.execute("FETCH ALL FROM itemcursor")
rec=loccur.fetchall()
print rec

However, following errors are produced in FC2 (python-2.3.3-6,
postgresql-7.4.2-1, kernel-2.6.8-1.521, pyPgSQL-2.4):

/usr/lib/python2.3/site-packages/pyPgSQL/PgSQL.py:2644: FutureWarning:
%u/%o/%x/%X of negative int will return a signed string in Python 2.4
and up
  name = "PgSQL_%08X" % id(self)
Traceback (most recent call last):
  File "tt1.py", line 5, in ?
    loccur.execute("DECLARE itemcursor CURSOR FOR \
  File "/usr/lib/python2.3/site-packages/pyPgSQL/PgSQL.py", line 3091,
in execute
    self.res = self.conn.conn.query('FETCH 1 FROM "%s"' % self.name)
libpq.OperationalError: ERROR:  cursor "PgSQL_F6F9906C" does not exist

Out of this, the first error is produced by conn.cursor() statement.

We have to use the "declare cursor" statement because we have to use
"fetch prior" statement later in the program. Is there a better way of
achiving this?

Something seems to have changed either python or in postgresql that is
causing this error. Can someone provide a solution/workaround?

Thanks in advance.
J Dubal.



More information about the Python-list mailing list