## Chapter 46. PL/Python — Python Procedural Language

**Table of Contents**

[46.1. Python 2 vs. Python 3](plpython-python23.html)

[46.2. PL/Python Functions](plpython-funcs.html)

[46.3. Data Values](plpython-data.html)

[46.3.1. Data Type Mapping](plpython-data.html#id-1.8.11.11.3)

[46.3.2. Null, None](plpython-data.html#id-1.8.11.11.4)

[46.3.3. Arrays, Lists](plpython-data.html#PLPYTHON-ARRAYS)

[46.3.4. Composite Types](plpython-data.html#id-1.8.11.11.6)

[46.3.5. Set-Returning Functions](plpython-data.html#id-1.8.11.11.7)

[46.4. Sharing Data](plpython-sharing.html)

[46.5. Anonymous Code Blocks](plpython-do.html)

[46.6. Trigger Functions](plpython-trigger.html)

[46.7. Database Access](plpython-database.html)

[46.7.1. Database Access Functions](plpython-database.html#id-1.8.11.15.3)

[46.7.2. Trapping Errors](plpython-database.html#PLPYTHON-TRAPPING)

[46.8. Explicit Subtransactions](plpython-subtransaction.html)

[46.8.1. Subtransaction Context Managers](plpython-subtransaction.html#id-1.8.11.16.3)

[46.8.2. Older Python Versions](plpython-subtransaction.html#id-1.8.11.16.4)

[46.9. Transaction Management](plpython-transactions.html)

[46.10. Utility Functions](plpython-util.html)

[46.11. Environment Variables](plpython-envar.html)

[]()[]()

 The PL/Python procedural language allows PostgreSQL functions and procedures to be written in the [Python language](https://www.python.org).

 To install PL/Python in a particular database, use `CREATE EXTENSION plpythonu` (but see also [Section 46.1](plpython-python23.html)).

### Tip

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

 PL/Python is only available as an “untrusted” language, meaning it does not offer any way of restricting what users can do in it and is therefore named `plpythonu`. A trusted variant `plpython` might become available in the future if a secure execution mechanism is developed in Python. The writer of a function in untrusted PL/Python must take care that the function cannot be used to do anything unwanted, since it will be able to do anything that could be done by a user logged in as the database administrator. Only superusers can create functions in untrusted languages such as `plpythonu`.

### 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.

