From PostgreSQL wiki
(Redirected from Plpython3)
Jump to: navigation, search

Feature-wise, this is done--actually, I plan to remove some features. If you are interested in seeing this in PostgreSQL, please drop an e-mail as I would like to know( x <at sign> jwp.name ).


pl/python3 is a procedural language implementation for Python 3.x

This WIP is targeting a patch for 8.5.

The git branch is located at http://git.postgresql.org/gitweb?p=plpython3.git;a=summary


  • Module based functions
  • Function PEP302 support (__loader__, for linecache support)
  • Tracebacks in CONTEXT
  • IST support (subtransactions)
  • Database Error support; Postgres Error -> Python Exception -> Postgres Error
  • SRFs (VPC and Materialized & Postgres.Cursor optimization)
  • Triggers (statement & row)
  • Type Interfaces (native typing)
  • Polymorphic types.
  • SPI/Prepared Statements and Cursors
  • Postgres.execute(sql_statements_string) (SPI_execute_statements() for bulk, parameter-less DDL/DML)
  • Large Object class (io.IOBase; some protocol conformance not possible, atm)
  • @pytypes decorator for converting Postgres.Object parameters to standard Python types
  • Properties to get parts of time types (ts.day, ddate.month, intv.second, etc)
  • Direct Function Calls (limited to non-polymorphic, non-SRF, and non-TRIGGER)
  • Stateful functions (Regular functions whose main is a generator =)
  • DO-statement support.
  • Postgres.preload(...) (Load all the Python functions in the specified schemas)
  • Tests [basic I/O, ISTs, Errors, SRFs, Triggers, Domains, Enums, SPI, Polymorphing]
  • Documentation with a substantial reference section

Quick Start

Basic installation using git.

Getting PostgreSQL with pl/python3

Use git, fresh clone of pg(if you don't already have one):

git clone git://git.postgresql.org/git/postgresql.git
cd postgresql

Fetch and checkout the plpython3 branch:

git remote add plpython3 git://git.postgresql.org/git/plpython3.git
git fetch plpython3
git branch plpython3 plpython3/plpython3
git checkout plpython3

Installing PostgreSQL with pl/python3

Like pl/python, pl/python3 can be configured and installed using a configure argument: --with-python3:

$ ./configure --with-python3

However, for testing, the following is recommended:

$ env "CFLAGS=-O0 -ggdb3" ./configure --enable-depend --enable-debug --enable-cassert --with-python3
# Don't forget to add an appropriate --prefix=

This relies on the python3 executable being accessible in the PATH. (Note: Python 3.0 is not supported, ATM. Use Python 3.1)

Once installed, the language can be created in a database using:


This uses the pg_pltemplate entry like other PLs.


Temporarily available here: