]> begriffs open source - ai-pg/blob - full-docs/html/plpython.html
Include links to all subsection html pages, with shorter paths too
[ai-pg] / full-docs / html / plpython.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Chapter 44. PL/Python — Python Procedural Language</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="plperl-under-the-hood.html" title="43.8. PL/Perl Under the Hood" /><link rel="next" href="plpython-funcs.html" title="44.1. PL/Python Functions" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">Chapter 44. PL/Python — Python Procedural Language</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="plperl-under-the-hood.html" title="43.8. PL/Perl Under the Hood">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="server-programming.html" title="Part V. Server Programming">Up</a></td><th width="60%" align="center">Part V. Server Programming</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="plpython-funcs.html" title="44.1. PL/Python Functions">Next</a></td></tr></table><hr /></div><div class="chapter" id="PLPYTHON"><div class="titlepage"><div><div><h2 class="title">Chapter 44. PL/Python — Python Procedural Language</h2></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="plpython-funcs.html">44.1. PL/Python Functions</a></span></dt><dt><span class="sect1"><a href="plpython-data.html">44.2. Data Values</a></span></dt><dd><dl><dt><span class="sect2"><a href="plpython-data.html#PLPYTHON-DATA-TYPE-MAPPING">44.2.1. Data Type Mapping</a></span></dt><dt><span class="sect2"><a href="plpython-data.html#PLPYTHON-DATA-NULL">44.2.2. Null, None</a></span></dt><dt><span class="sect2"><a href="plpython-data.html#PLPYTHON-ARRAYS">44.2.3. Arrays, Lists</a></span></dt><dt><span class="sect2"><a href="plpython-data.html#PLPYTHON-DATA-COMPOSITE-TYPES">44.2.4. Composite Types</a></span></dt><dt><span class="sect2"><a href="plpython-data.html#PLPYTHON-DATA-SET-RETURNING-FUNCS">44.2.5. Set-Returning Functions</a></span></dt></dl></dd><dt><span class="sect1"><a href="plpython-sharing.html">44.3. Sharing Data</a></span></dt><dt><span class="sect1"><a href="plpython-do.html">44.4. Anonymous Code Blocks</a></span></dt><dt><span class="sect1"><a href="plpython-trigger.html">44.5. Trigger Functions</a></span></dt><dt><span class="sect1"><a href="plpython-database.html">44.6. Database Access</a></span></dt><dd><dl><dt><span class="sect2"><a href="plpython-database.html#PLPYTHON-DATABASE-ACCESS-FUNCS">44.6.1. Database Access Functions</a></span></dt><dt><span class="sect2"><a href="plpython-database.html#PLPYTHON-TRAPPING">44.6.2. Trapping Errors</a></span></dt></dl></dd><dt><span class="sect1"><a href="plpython-subtransaction.html">44.7. Explicit Subtransactions</a></span></dt><dd><dl><dt><span class="sect2"><a href="plpython-subtransaction.html#PLPYTHON-SUBTRANSACTION-CONTEXT-MANAGERS">44.7.1. Subtransaction Context Managers</a></span></dt></dl></dd><dt><span class="sect1"><a href="plpython-transactions.html">44.8. Transaction Management</a></span></dt><dt><span class="sect1"><a href="plpython-util.html">44.9. Utility Functions</a></span></dt><dt><span class="sect1"><a href="plpython-python23.html">44.10. Python 2 vs. Python 3</a></span></dt><dt><span class="sect1"><a href="plpython-envar.html">44.11. Environment Variables</a></span></dt></dl></div><a id="id-1.8.11.2" class="indexterm"></a><a id="id-1.8.11.3" class="indexterm"></a><p>
3   The <span class="application">PL/Python</span> procedural language allows
4   <span class="productname">PostgreSQL</span> functions and procedures to be written in the
5   <a class="ulink" href="https://www.python.org" target="_top">Python language</a>.
6  </p><p>
7   To install PL/Python in a particular database, use
8   <code class="literal">CREATE EXTENSION plpython3u</code>.
9  </p><div class="tip"><h3 class="title">Tip</h3><p>
10     If a language is installed into <code class="literal">template1</code>, all subsequently
11     created databases will have the language installed automatically.
12    </p></div><p>
13   PL/Python is only available as an <span class="quote">“<span class="quote">untrusted</span>”</span> language, meaning
14   it does not offer any way of restricting what users can do in it and
15   is therefore named <code class="literal">plpython3u</code>.  A trusted
16   variant <code class="literal">plpython</code> might become available in the future
17   if a secure execution mechanism is developed in Python.  The
18   writer of a function in untrusted PL/Python must take care that the
19   function cannot be used to do anything unwanted, since it will be
20   able to do anything that could be done by a user logged in as the
21   database administrator.  Only superusers can create functions in
22   untrusted languages such as <code class="literal">plpython3u</code>.
23  </p><div class="note"><h3 class="title">Note</h3><p>
24    Users of source packages must specially enable the build of
25    PL/Python during the installation process.  (Refer to the
26    installation instructions for more information.)  Users of binary
27    packages might find PL/Python in a separate subpackage.
28   </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="plperl-under-the-hood.html" title="43.8. PL/Perl Under the Hood">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="server-programming.html" title="Part V. Server Programming">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="plpython-funcs.html" title="44.1. PL/Python Functions">Next</a></td></tr><tr><td width="40%" align="left" valign="top">43.8. PL/Perl Under the Hood </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 44.1. PL/Python Functions</td></tr></table></div></body></html>