Supported Versions: Current (16) / 15 / 14 / 13 / 12
Development Versions: devel
Unsupported versions: 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 8.1 / 8.0 / 7.4 / 7.3 / 7.2
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 40. PL/Python - Python Procedural Language

Table of Contents
40.1. PL/Python Functions
40.2. Trigger Functions
40.3. Database Access

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.

Tip: If a language is installed into template1, all subsequently created databases will have the language installed automatically.

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.

Note: Users 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.