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 have a simple in-memory graph database engine that is
not concerned with performance. The ideal use-case is for testing programs that
generate small openCypher queries, or as an alternative reference
implementation.
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:
python3 -m build
cd dist/
pip install *.whl
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
Hashes for spycy_aneeshdurg-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f16356b5d18433145f64031e46233a9036dc455db8516c94c2c7388bae32c000 |
|
MD5 | e7930f2fc89bbb0a350e02b2c7acc0eb |
|
BLAKE2b-256 | 903f39cc202665cca68d6034f925e02ddeeddea5649ee6633cc0d0e158364542 |