Search Postgresql Archives

Re: How to 'register' functions, so they can be called (plpythonu)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



blay bloo wrote:
> I am defining some functions using plpythonu, through the standard means.
> 
> Here I have one function (test1) which calls another (testfunc). When
> I excute this I get the following error:
> 
> ERROR:  plpython: function "test1" failed
> DETAIL:  <type 'exceptions.NameError'>: global name 'testfunc' is not defined
> 
> However, from the console, select testfunc('test') works fine.
> 
> I was wondering how do I 'register'/'reference' these functions so
> that one function can call another?

You can't, because the name you give to the function lives in Postgres'
namespace, not Python's.  Therefore you can only call the other function
using the SPI interface that PL/Python offers you.

> I am guessing this is important,
> i.e. how will I access the complete functionality of the general
> python libs?

This is quite different -- I'm guessing the Python library can be
accessed via normal means.  What you cannot do is use Postgres' CREATE
FUNCTION to define a regular Python function (i.e. you cannot extend the
"library").

-- 
Alvaro Herrera                        http://www.advogato.org/person/alvherre
Bob [Floyd] used to say that he was planning to get a Ph.D. by the "green
stamp method," namely by saving envelopes addressed to him as 'Dr. Floyd'.
After collecting 500 such letters, he mused, a university somewhere in
Arizona would probably grant him a degree.              (Don Knuth)

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux