openCypher implemented in python
Project description
sPyCy
sPyCy is a python implementation of openCypher. Try it out in your browser here: https://aneeshdurg.me/spycy
The goal of sPyCy
is to enable using openCypher as a frontend, or to embed
openCypher in other projects. To this end, sPyCy
is quite modular and several
components such as the underlying graph implementation, the subgraph pattern
matcher, and the expression evaluator can all be substituted with a custom
implementation. See examples/
for some sample usage.
The long-term goals of this project include fully passing all openCypher TCK tests. Currently a majority of TCK tests are expected to pass. The failing tests are documented.
Some major unimplemented features are MERGE
, temporal values, WHERE
predicates involving patterns, existential subqueries, and CALL
.
Installation
You can either install from PyPI or build sPyCy
yourself. To install the pre-built wheel, run:
pip install spycy_aneeshdurg
To build it yourself, from the root of this repo, run:
# Optional - create and enter a venv
# python3 -m venv venv
# source ./venv/bin/activate # this command varies from shell to shell
pip install .
Usage:
# Example usage:
python3 -m spycy --query "CREATE (a {id: 'node0'})-[:X]->(b) return a"
# Or interactive mode:
python3 -m spycy --interactive
> CREATE (a {id: 'node0'})-[:X]->(b {id: 'node1'})
> MATCH (a)--(b) RETURN a.id, b.id
a.id b.id
0 node0 node1
sPcY
can also be used via python:
from spycy import spycy
exe = spycy.CypherExecutor()
ids = list(range(100))
exe.exec(f"UNWIND {ids} as x CREATE ({{id: x}})")
num_nodes_gt_10 = exe.exec("MATCH (a) WHERE a.id > 10 RETURN count(a) as output")["output"]
print(f"There are {num_nodes_gt_10} node(s) with an id greater than 10")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file spycy_aneeshdurg-0.0.3.tar.gz
.
File metadata
- Download URL: spycy_aneeshdurg-0.0.3.tar.gz
- Upload date:
- Size: 20.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d1d5fef876ce2150d0de9f3efb1cb9b50c93dce0fdcfa9675fe264806743e37 |
|
MD5 | 8fbd1d6d7d0e3169f778e394d23c8bd3 |
|
BLAKE2b-256 | 07cef5d6f49dc8d177bf8dcd87f66949c8bf2180ab952c93704851460328d8ff |
File details
Details for the file spycy_aneeshdurg-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: spycy_aneeshdurg-0.0.3-py3-none-any.whl
- Upload date:
- Size: 134.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e220f9a210f6bc0512552f29bb929f11900693ebf3e18c088f374b9dcc94505 |
|
MD5 | af470fa8803816fe15e4881aaa9d38cb |
|
BLAKE2b-256 | be2192819ba37a75cd2d5a03a861df0822c8f943df32dbb4594703b1434448bd |