Pl/python-python Procedural Language installation
- Check that the system provides the Plpython package (already compiled).
[[email protected] ~]# DNF search python |grep postgresqlpython3-postgresql.x86_64:connect to PostgreSQL with Python 3python-storm-postgresql.x86_64:postgresql backend for python-stormpostgresql-plpython.x86_64 : The Python2 procedural language for postgresqlpostgresql95-plpython.x86_64:the Python procedural language for PostgreS Qlpostgresql94-plpython.x86_64:the Python Procedural language for postgresqlpostgresql-plpython3.x86_64:the Python3 p Rocedural Language for Postgresqlpostgresql94-python-debuginfo.x86_64:debug information : postgresql94-pythonpostgresql94-python.x86_64:development module for Python code to access apython-tes ting.postgresql.noarch:Automatically setup a PostgreSQL testingpython3-testing.postgresql.noarch:automatically Setup a PostgreSQL testing
I'm using the FEDORA22 system. Postgresql-plpython.x86_64, postgresql-plpython3.x86_64 is what we need to install (both Python2 and Python3 versions are supported).
- Installing the plug-in package
[[email protected] ~]# dnf install postgresql-plpython.x86_64[[email protected] ~]# dnf install postgresql-plpython3.x86_64
- Check to see if the installation directory has plugins:
-bash-4.3$ pwd/usr/share/pgsql/extension-bash-4.3$ ll |grep python-rw-r--r--. 1 root root 351 6月 13 03:06 plpython2u--1.0.sql-rw-r--r--. 1 root root 196 6月 13 03:06 plpython2u.control-rw-r--r--. 1 root root 402 6月 13 03:06 plpython2u--unpackaged--1.0.sql-rw-r--r--. 1 root root 351 6月 13 03:06 plpython3u--1.0.sql-rw-r--r--. 1 root root 196 6月 13 03:06 plpython3u.control-rw-r--r--. 1 root root 402 6月 13 03:06 plpython3u--unpackaged--1.0.sql-rw-r--r--. 1 root root 347 6月 13 03:06 plpythonu--1.0.sql-rw-r--r--. 1 root root 194 6月 13 03:06 plpythonu.control-rw-r--r--. 1 root root 393 6月
Plpython3u.control, Plpython2u.control and so on have already.
- PG Database Installation Plpython extension
CREATE EXTENSION plpython3u; CREATE EXTENSION plpython2u;
The above SQL execution can be performed in the Pgadmin IDE tool (with privileged users). You can see if the extension is installed.
CREATE FUNCTION pymax (a integer, b integer) RETURNS integerAS $$ if a > b: return a return b$$ LANGUAGE plpython3u;
Execute:
select pymax(12,13);
Output 13.
Pgadmin view the extensions that have been installed:
Error Handling:
Error handling error: Unable to open extension control file "/usr/share/pgsql/extension/plpythonu3.control": No file or directory
Fatal error **********
Error: Unable to open extension control file "/usr/share/pgsql/extension/plpythonu3.control": No file or directory SQL status: 58P01
The above error indicates that the plug-in installation package is not installed correctly. You must ensure that the PG extension is in the directory.
Copyright NOTICE: This article for Bo Master original article, without BO Master permission cannot reprint http://blog.csdn.net/doctor_who2004.
PostgreSQL Pl/python-python Procedural Language Installation