Skip to content

neo4j-fdw

Multicorn-based foreign data wrapper and Cypher functions for Neo4j.

neo4j-fdw · Multicorn-based foreign data wrapper and Cypher functions for Neo4j.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100115neo4j-fdwneo4j-fdw4.3.2FDWGPL-3.0Python

PostgreSQL · 10, 11, 12

Relationships
Requiresmulticorn plpython3u

Usage

Sources:

neo4j-fdw is an archived Python integration that uses Multicorn to expose a Neo4j Cypher result as a PostgreSQL foreign table. It is not a native FDW library: the PostgreSQL server process imports the separately installed neo4jPg Python package, the Neo4j Python driver, and Multicorn.

Core Workflow

After installing a mutually compatible Python, Multicorn, and Neo4j-driver stack, create the Multicorn server and map one aliased Cypher result to one foreign table:

CREATE EXTENSION multicorn;

CREATE SERVER multicorn_neo4j
FOREIGN DATA WRAPPER multicorn
OPTIONS (
  wrapper 'neo4jPg.neo4jfdw.Neo4jForeignDataWrapper',
  url 'neo4j://neo4j.example:7687',
  user 'neo4j',
  password 'replace-me'
);

CREATE FOREIGN TABLE neo4j_movie (movie text)
SERVER multicorn_neo4j
OPTIONS (
  cypher 'MATCH (n:Movie) RETURN n.title AS movie',
  database 'neo4j'
);

SELECT * FROM neo4j_movie WHERE movie ILIKE '%matrix%';

The Cypher expression must return a collection and alias every returned field to a foreign-table column. Simple comparison and pattern qualifiers can be rewritten into Cypher; optional strict /*WHERE{...}*/ placeholders tell the wrapper where to insert predicates more efficiently.

Packaging and Compatibility Boundaries

The canonical project name is neo4j-fdw, but the reviewed source is not a reliable modern extension bundle. Its control file reports 4.3.2-dev, while the repository installs an unversioned SQL file rather than a matching versioned extension script. That SQL also requests the legacy plpythonu extension but declares functions in plpython3u. Validate and patch packaging instead of assuming that CREATE EXTENSION "neo4j-fdw" succeeds.

The FDW table path above needs Multicorn and the Python package; the optional direct cypher() SQL helpers additionally need untrusted PL/Python. Upstream’s stated PostgreSQL compatibility ends at 12, and the repository was archived in 2023. Credentials are stored as foreign-server options. Restrict catalog and server privileges, use a dedicated Neo4j account and encrypted transport, and test query generation against the exact Neo4j driver/server pair.

Table reader