企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# Chapter 43\. PL/Python - Python 过程语言 **Table of Contents** + 43.1\. Python 2 vs. Python 3 + 43.2\. PL/Python Functions + 43.3\. Data Values + 43.3.1\. Data Type Mapping + 43.3.2\. Null, None + 43.3.3\. Arrays, Lists + 43.3.4\. Composite Types + 43.3.5\. Set-returning Functions + 43.4\. Sharing Data + 43.5\. Anonymous Code Blocks + 43.6\. Trigger Functions + 43.7\. Database Access + 43.7.1\. Database Access Functions + 43.7.2\. Trapping Errors + 43.8\. Explicit Subtransactions + 43.8.1\. Subtransaction Context Managers + 43.8.2\. Older Python Versions + 43.9\. Utility Functions + 43.10\. Environment Variables PL/Python 过程语言允许用Python语言编写 PostgreSQL 函数。 [Python 语言](http://www.python.org). 要在特定的数据库里安装PL/Python,使用 `CREATE EXTENSION plpythonu`,或者使用命令行工具 `createlang plpythonu` `_数据库名称_` (详见[Section 43.1](#calibre_link-883))。 > **Tip:** 如果一门语言安装到了`template1`数据库中,那么所有的随后创建的数据库都会自动的安装该语言。 到目前为止PostgreSQL , PL/Python 只能当成 一种"不可信任的" 语言,意思是他没有提供任何限制用户可为与不可为的手段,因此 他被重命令为 `plpythonu`,可信任的 `plpython` 可能在将来某个时间能够获得 if a new 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.