Re: Call postgres PL/Python stored function from another PL/Python block. - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Call postgres PL/Python stored function from another PL/Python block.
Date
Msg-id 569691B5.9030706@aklaver.com
Whole thread Raw
In response to Call postgres PL/Python stored function from another PL/Python block.  (lodopidolo <dir.postgresql@orencio.org>)
Responses Re: Call postgres PL/Python stored function from another PL/Python block.
List pgsql-general
On 01/13/2016 07:47 AM, lodopidolo wrote:
> Hello. It is possible to call al PL/Python stored function natively from
> another PL/Python function?
>
> Something like:
>
> |createorreplace functionf1()returns text as$$return"hello"$$language
> 'plpython3u';|
>
> |do $$begin...t =f1()...end;$$language 'plpython3u';|
>
>
> Regards.
>
> (this question has been made in
> http://stackoverflow.com/questions/34764665/call-postgres-pl-python-stored-function-from-another-pl-python-block
> too).

In addition to the other answers there is the option of just creating
the function in a Python module outside Postgres and doing:

from some_module import f

Which would seem to address this(from the SO post):

"This can be done using t = plpy.execute("select f1()"), but I want, if
it is possible, call it as a normal Python function to avoid type
conversions (for example jsonb, etc)."

The downside being you have a dependency outside the database.

--
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: Vick Khera
Date:
Subject: Re: Blocked updates and background writer performance
Next
From: Jim Nasby
Date:
Subject: Re: Moving a large DB (> 500GB) to another DB with different locale