Re: PL/Python - Mailing list pgsql-general

From Joe Abbate
Subject Re: PL/Python
Date
Msg-id 4E887818.5030805@freedomcircle.com
Whole thread Raw
In response to Re: PL/Python  (Sim Zacks <sim@compulab.co.il>)
Responses Re: PL/Python  (Sim Zacks <sim@compulab.co.il>)
List pgsql-general
Hi Sim,

On 10/02/2011 08:02 AM, Sim Zacks wrote:
> If I understand plpython correctly, it uses the python installed on the
> machine. In other words, plpythonu doesn't support the new style
> classes, it depends on what version of python is installed.

Well, Python has had new style classes since 2.2 (December 2001).  PG
8.2 release notes says it supports Python 2.5 and the 9.0 notes show
support was added for Python 3.  Unless someone is running Python 2.1 or
earlier, it seems new style classes are available.

> In the same way, if you have libraries installed on your machine,
> plpythonu has access to them as well. So if someone installed pyrseas,
> he would be able to use all the functions from within his function.

Yes, that seems to be the case, assuming the path to the library is
visible in (or added to) PYTHONPATH.

> IMO, there is no need for an extension here, all you need to do is have
> an sql file containing your 2 plpythonu functions that can be run into
> the database.

Maybe I'm misunderstanding something, but isn't such a sql file an
extension or is 95% of the way there?  Pyrseas is already distributed
via PGXN, but like some other PGXN "extensions" (dbi-link?), it doesn't
actually create functions in the database.  Its two utilities run
entirely as external programs.  If the Pyrseas functions were added via
an .sql file to a database, EXTENSION or not, they would be available
for use by non-Pyrseas programs, e.g., pgAdmin could call diff_map() to
compare database objects, Perl scripts or even a plain psql script could
call to_yaml().  And these would not depend on psycopg2, which currently
*is* a Pyrseas dependency (it would still be necessary for access to the
command line utilities).

Joe

pgsql-general by date:

Previous
From: Cédric Villemain
Date:
Subject: Re: How to find freak UTF-8 character?
Next
From: Leif Biberg Kristensen
Date:
Subject: Re: How to find freak UTF-8 character?