multicorn
multicorn : Fetch foreign data in Python in your PostgreSQL server.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 8510 | multicorn | multicorn | 3.2 |
FDW | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-- | No | Yes | No | Yes | no | no |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PGDG | 3.2 |
18 17 16 15 14 | multicorn |
- |
| RPM | PGDG | 3.2 |
18 17 16 15 14 | multicorn2_$v |
- |
| DEB | PIGSTY | 3.2 |
18 17 16 15 14 | postgresql-$v-multicorn |
python3-multicorn |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 |
| el8.aarch64 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 |
| el9.x86_64 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 |
| el9.aarch64 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 |
| el10.x86_64 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 |
| el10.aarch64 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 | PGDG 3.2 |
| d12.x86_64 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 |
| d12.aarch64 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 |
| d13.x86_64 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 |
| d13.aarch64 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 |
| u22.x86_64 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 |
| u22.aarch64 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 |
| u24.x86_64 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 |
| u24.aarch64 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 |
| u26.x86_64 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 |
| u26.aarch64 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 | PIGSTY 3.2 |
Source
github.com/pgsql-io/multicorn2
multicorn2-3.2.tar.gz
Install
Make sure PGDG repo available:
Install this extension with pig:
Create this extension with:
Usage
Multicorn2 allows you to write Foreign Data Wrappers in Python. You implement a Python class that inherits from multicorn.ForeignDataWrapper, and Multicorn handles bridging it to PostgreSQL’s FDW interface. Version 3.2 is tested with PostgreSQL 14-18 and Python 3.9-3.13, though upstream recommends Python 3.10-3.12 for near-term distro compatibility.
Define a Python FDW Class
Create a Python module (e.g., myfdw.py) accessible to the PostgreSQL process:
Create Server and Foreign Table
The wrapper option specifies the fully qualified Python class name. Any additional options are passed to the class constructor’s options parameter.
Built-in FDW Examples
Multicorn ships with several example FDW implementations that can be used directly or as reference:
- CsvFdw – read CSV files
- ProcessFdw – execute system commands and parse output
- GCalFdw – access Google Calendar
- ImapFdw – query IMAP mailboxes
- RssFdw – read RSS/Atom feeds
Version Notes
Multicorn 3.2 adds basic OFFSET/LIMIT pushdown and LDAP paging support, and fixes LDAP right-parenthesis escaping. Upstream 3.1 added PostgreSQL 18 and Python 3.13 support while dropping PostgreSQL versions before 14.
Caveats
Multicorn2 and PL/Python are incompatible in the same PostgreSQL database on Python 3.12 due to CPython limitations. They can be installed on the same system, but avoid enabling both in one database.