GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||
GeezerVison is showing www.postgresql.org — PL/Python - Python Procedural Language November 19, 2026: PostgreSQL 19 Released!
Development Versions:
devel
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.
Chapter 38. PL/Python - Python Procedural Language
The PL/Python procedural language allows PostgreSQL functions to be written in the Python language. To install PL/Python in a particular database, use createlang plpythonu dbname.
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 plpythonu. The trusted variant plpython may become available again in future, if a new secure execution mechanism is developed in Python.
38.1. PL/Python FunctionsFunctions in PL/Python are declared in the usual way, 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 None. PL/Python translates Python's None into the SQL null value. The PostgreSQL function
parameters are available in the global args list. In the The global dictionary SD is available to store data between function calls. This variable is private static data. The global dictionary GD is public data, available to all Python functions within a session. Use with care. Each function gets its own execution environment in the
Python interpreter, so that global data and function arguments
from | ||||||||||
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. | ||||||||||