This project has been archived by its maintainers, and is no longer receiving any updates.
pcypher
Overview
Pcypher is a Python library to parse Cypher queries.
Table of Contents
- Prerequisites
- Installation
- Usage as CLI command
- Usage as Python library
- Release Notes
- Known Issues
- License
Prerequisites
- Python 3.9 or higher
Installation
pcypher offers two options of use patterns:
- CLI command to parse Cypher queries
- Python library to parse Cypher queries
As a CLI command, install pcypher with brew.
brew tap rioriost/pcypher
brew install pcypher
As a Python library, install pcypher with pip / uv.
python venv on macOS, Linux
mkdir your_directory
cd your_directory
python3 -m venv venv
source venv/bin/activate
python3 -m pip install pcypher
uv on macOS, Linux
uv init your_directory
cd your_directory
uv venv
source .venv/bin/activate
uv add pcypher
python venv on Windows
md your_directory
cd your_directory
python -m venv venv
source .\venv\Scripts\activate
python -m pip install pcypher
Usage as CLI command
Execute pcypher command.
pcypher --help
usage: pcypher [-h] query
positional arguments:
query Query to parse
optional arguments:
-h, --help show this help message and exit
pcypher "CREATE (adam:User {name: 'Adam'}), (pernilla:User {name: 'Pernilla'}), (david:User {name: 'David'}), (adam)-[:FRIEND]->(pernilla), (pernilla)-[:FRIEND]->(david)"
[('CREATE', [('node', 'adam', ['User'], [('name', 'Adam')]), ('node', 'pernilla', ['User'], [('name', 'Pernilla')]), ('node', 'david', ['User'], [('name', 'David')]), ('chain', ('node', 'adam', [], None), [(('directed', ('relationship', [{'variable': None, 'type': 'FRIEND'}], None, None)), ('node', 'pernilla', [], None))]), ('chain', ('node', 'pernilla', [], None), [(('directed', ('relationship', [{'variable': None, 'type': 'FRIEND'}], None, None)), ('node', 'david', [], None))])])]
Usage as Python library
from pcypher import CypherParser
def main():
query = "CREATE (adam:User {name: 'Adam'}), (pernilla:User {name: 'Pernilla'}), (david:User {name: 'David'}), (adam)-[:FRIEND]->(pernilla), (pernilla)-[:FRIEND]->(david)"
parser = CypherParser()
result = parser.parse(query)
print(f"{str(result)}")
if __name__ == "__main__":
main()
Release Notes
0.1.0 Release
- Initial release.
Known Issues
- pcypher is based on the Cypher Query Language Reference, Version 9. pcypher 0.1.0 can not parse the following four queries in the reference.
"""MATCH (martin:Person {name: 'Martin Sheen'}), (oliver:Person {name: 'Oliver Stone'}), p = shortestPath((martin)-[*..15]-(oliver)) RETURN p""", # in page 67
"""MATCH (martin:Person {name: 'Martin Sheen'}), (michael:Person {name: 'Michael Douglas'}), p = allShortestPaths((martin)-[*]-(michael)) RETURN p""", # in page 67
"""MATCH (n:Member) RETURN org.opencypher.function.example.join(collect(n.name)) AS members""", # in page 193
"""MATCH (n:Member) RETURN org.opencypher.function.example.longestString(n.name) AS member""", # in page 193
License
MIT License
Metadata
Release files for pcypher 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pcypher-0.1.0.tar.gz | 24.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pcypher-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 46.5 kB
Release files / pcypher-0.1.0.tar.gz
| Download URL | pcypher-0.1.0.tar.gz |
|---|---|
| Size | 24.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
97c4c418e70931eea5e93a2287b5beb0c55ff88ba2f2c4baaa3118d89c217659
|
|
BLAKE2b-256 checksum How to use checksums |
cc434058181d544347a73bd89ee79d9993c97e7a55190fc09c8424471652a188
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.27
|
Release files / pcypher-0.1.0-py3-none-any.whl
| Download URL | pcypher-0.1.0-py3-none-any.whl |
|---|---|
| Size | 22.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b4d372328504eaaf2b9f45b0f53f811e1e1b31a87dd73e7cfe29499d6e9522b2
|
|
BLAKE2b-256 checksum How to use checksums |
7f4ac1d6f0c055b0ed0b559a96aa99408bbb7b591e00903044a6a29533223c71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.27
|
Security for pcypher 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.