|
|
| · · · · · · · | |
pgAdmin 1.4 online documentationChapter 39. PL/Python - Python Procedural LanguageTable of Contents The PL/Python procedural language allows PostgreSQL functions to be written in the Python language. To install PL/Python in a particular database, use
Tip If a language is installed into As of PostgreSQL 7.4, PL/Python is only
available as an “untrusted” language (meaning it does not
offer any way of restricting what users can do in it). It has
therefore been renamed to NoteUsers of source packages must specially enable the build of PL/Python during the installation process. (Refer to the installation instructions for more information.) Users of binary packages might find PL/Python in a separate subpackage. 39.1. PL/Python FunctionsFunctions in PL/Python are declared via the usual CREATE FUNCTION syntax. For example: CREATE FUNCTION myfunc(text) RETURNS text
AS 'return args[0]'
LANGUAGE plpythonu;
The Python code that is given as the body of the function definition gets transformed into a Python function. For example, the above results in def __plpython_procedure_myfunc_23456():
return args[0]
assuming that 23456 is the OID assigned to the function by PostgreSQL. If you do not provide a return value, Python returns the default
The PostgreSQL function parameters are available in
the global The global dictionary Each function gets its own execution environment in the
Python interpreter, so that global data and function arguments from
|