Skip to content Skip to sidebar Skip to footer

How To Get Returned Query Object Of Postgresql Function In Python?

With pgsql function SelRec(integer) as defined below: -- select record CREATE OR REPLACE FUNCTION SelRec(_sno integer) RETURNS SETOF app_for_leave AS $BODY$ BEGIN RETURN

Solution 1:

I think it might be expected behavior.

From the docs http://initd.org/psycopg/docs/cursor.html#cursor.execute

The method returns None. If a query was executed, the returned values can be retrieved using fetch*() methods.

Try something like:

print(dir(obj), type(obj))
print(cursor.fetchall())

Solution 2:

I think you should try query given below. As you want to return set of rows.

select*from SelRec(1) asresult (sno int, eid int, ename varchar, sd data_type, ed data_type, sid int, status boolean)

Post a Comment for "How To Get Returned Query Object Of Postgresql Function In Python?"