python - How to return resultset with Plpython3 in Postgres -


how can plpython function return result set normal sql query resultset (not text).

here function definition -

drop function if exists demo_report(); create or replace function demo_report()     returns setof <what-type> $$     rv = plpy.execute("select * test")     return rv $$ language plpython3u; 

when execute select demo_report(); should return resultset client rather text.right getting text - enter image description here

i using postgres 9.2 plpython3u on windows.

i found way desired result - table :

create table public.test (    id serial not null,    name   varchar(200) not null check (name <> ''),    salary int,    created  date,    constraint id primary key (id), )  (   oids = false,   autovacuum_enabled = true ); 

my plpython3u function -

create or replace function demo_report()   returns setof test $$   resp = []   rv = plpy.execute("select * test")   in rv:     resp.append(i)   return resp  $$ language 'plpython3u' volatile; 

and query -

select * demo_report(); 

now getting desired response - enter image description here

its been quite nice journey plpython till now. enjoying it.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -