Share

Python Interface to PostgreSQL

Tracker: Bugs

5 callproc result set not retrievable - ID: 1924687
Last Update: Tracker Item Submitted ( aminusfu )

The Cursor.callproc method in pyPgSQL (at least up to version 1.5) has two
problems. First, it takes *args instead of a single args parameter, which
is contrary to the DBAPI spec and most other implementations of it. Second,
it calls 'select proc(args)', which does not allow fetchall() to retrieve
its return value. Therefore, this patches pyPgSQL.Cursor.callproc to take a
single args param, and to execute 'select * from proc(args)', which allows
fetchall() to work properly. It'd be nice if a future version of pyPgSQL
used the "*" form of the call.


from pyPgSQL import PgSQL as pgsql
if not hasattr(pgsql.Cursor, "_old_callproc"):
def callproc2(self, proc, args):
"""
Call a stored procedure with a fetchable return value.

Note that this takes a single args attribute instead
of *args.

"""
return self._old_callproc(" * from " + proc, *args)
pgsql.Cursor._old_callproc = pgsql.Cursor.callproc
pgsql.Cursor.callproc = callproc2


Robert Brewer ( aminusfu ) - 2008-03-24 22:00

5

Open

None

Nobody/Anonymous

PgConnection

None

Public


Comments

No follow-up comments have been posted.

Attached File

No Files Currently Attached

Change

No changes have been made to this artifact.