Use cursor.executeany("cypher", query, namespace=graph_namespace) to run one Cypher statement in a labeled property graph namespace. Omit params because the current Polypheny server only supports direct Cypher execution. Call commit() to persist writes and read cursor.rowcount when the server returns a scalar update count. Cursor reference · Cypher language guide · Prism result formats
Installation
Install the connector from the source repository in a virtual environment with Python 3.9 or later. The connector uses the Prism 2.3 bindings. Use a Polypheny server with Prism graph support and the Cypher language enabled. Mixed graph and scalar projections require Prism 2.3. Python connector source
python -m pip install "polypheny @ git+https://github.com/polypheny/Polypheny-Connector-Python.git@master"
Result shapes
The projection determines the shape each fetch returns.
| Cypher projection | Python result |
|---|---|
MATCH (n:Person) RETURN n |
A flat stream of node dictionaries. |
MATCH (a)-[r]->(b) RETURN a, r, b |
A flat stream of node, edge, and node dictionaries for each matched row. |
MATCH p=(a)-[r]->(b) RETURN p |
A flat stream of the path’s nodes and edges in traversal order. |
MATCH (*) RETURN * |
A full-graph scan streamed as nodes followed by edges. |
MATCH (n:Person) RETURN n.name AS name |
Tabular rows such as ["Ada"]. |
MATCH (n:Person) RETURN n, n.name AS name |
Tabular rows with a node dictionary and a string in separate cells. |
MATCH p=(a)-[r]->(b) RETURN p, b.name AS name |
Tabular rows with a path dictionary and a string in separate cells. |
A flat stream has no column metadata or matched-row boundaries. It can repeat an element that occurs in several rows or paths. It omits null graph values. A mixed projection preserves row boundaries and null cells, and cursor.description contains the column names and aliases. Use explicit patterns and named return expressions for mixed projections.
Mixed projections still expose column names and aliases when the query matches zero rows. In that case, fetchone() returns None and fetchall() returns an empty list.
Use fetchone(), fetchmany(), fetchall(), or iterate over the cursor. Each fetch counts graph elements in a flat stream or rows in a tabular result. A positive fetch_size limits source rows per server frame, so a single path can yield several elements even with fetch_size=1.
Graph dictionaries
| Value | Keys |
|---|---|
| Node | id is the internal node ID. name is the Cypher variable name when the server supplies one and can be an empty string. labels is a list of strings. properties maps property names to Python values. |
| Edge | The same keys as a node, plus left and right for the endpoint IDs and direction for the orientation relative to those endpoints. |
| Path | nodes and edges lists in traversal order. Edge i connects node i with node i + 1 and keeps its stored orientation. A path can revisit a node. |
| Graph | nodes and edges lists with no ordering guarantee. The node list includes isolated nodes. |
Read a stored property such as a person’s name with node["properties"]["name"]. Use node["id"] to match the endpoint IDs of an edge. The integer direction is 0 for UNSPECIFIED, 1 for LEFT_TO_RIGHT, 2 for RIGHT_TO_LEFT, and 3 for NONE. Property values and nested graph values use the same type conversions as tabular cells. Python value conversion · Prism 2.3 graph value definitions
The connector exposes graph dictionaries as result values. Build or modify graphs with Cypher statements. The current server rejects graph-typed bind parameters.
The Prism catalog can identify a matching graph through EntitiesResponse. The graph metadata message is an empty marker. Use Cypher to inspect nodes, edges, labels, and properties. Prism entity metadata
Run the Python integration example to see graph paging, mixed results, column aliases, and ordered path traversal. Query a graph with Cypher