PL/Python is a procedural language for PostgreSQL that allows you to write functions and triggers in Python as opposed to PL/pgSQL. It is of note while PL/Python is the higher level extension, in particular we support PL/Python3u which is the Python 3 version. All databases come with the extension available, but you need to enable it:


Once enable you can create your functions by specifying the plpython3u language on CREATE FUNCTION:

CREATE FUNCTION pymax (a integer, b integer)
  RETURNS integer
AS $$
  if a > b:
    return a
  return b
$$ LANGUAGE plpython3u;


In addition to the standard library we also currently install a number of packages for Python to allow you to do more. At this time we support:

If you wish to have support for an additional library please contact us.

Further reading

For some additional guidance take a look at these articles and references:

Getting started with Postgres functions in PL/Python
Building a recommendation engine inside Postgres with Pandas and Python