https://github.com/accenture/cymple
Cymple - a productivity tool for creating Cypher queries in Python
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.7%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Cymple - a productivity tool for creating Cypher queries in Python
Basic Info
Statistics
- Stars: 56
- Watchers: 6
- Forks: 7
- Open Issues: 3
- Releases: 0
Topics
Metadata Files
README.md
Cymple - Cypher Modular Pythonic Language Extension
A productivity tool for creating Cypher queries in Python.
About the project
Cymple is a lightweight Python package for creating queries in Cypher, Neo4j's graph database query language. Give it a try, it's 'Cymple'!
Consider using Cymple if you want: * auto-completion for writing Cypher * to write compound Cypher queries without getting involved with strings * to write Cypher queries in a scalable and extensible manner * to be able to easily reuse Cypher queries across your code

Getting Started
Setup
shell
pip install cymple
Examples
Simple Example
Let's take a look at the following snippet. ```python from cymple import QueryBuilder
qb = QueryBuilder()
query = qb.match().node(labels='Person', refname='p')
query = query.where('p.name', '=', '"Michelle"').returnliteral('p')
print(query)
This snippet will output the following Cypher query:
cypher
MATCH (p: Person) WHERE p.name = "Michelle" RETURN p
```
See the samples directory for examples.
Cymple is intended for creating Cypher queries in Python, rather than executing queries on an actual DB.
For executing queries, see Neo4j's Bolt driver for Python. See also neo4j_e2e.py in the samples directory.
Autocompletion
Cymple is designed to provide autocompletion on IDEs that support autocompletion. This feature is context aware with respect to the current query being written.

Reusing Queries
Two queries can be combined to a create a new one.
python
qb = QueryBuilder()
query1 = qb.match().node(labels='Person', ref_name='p').with_('p')
query2 = qb.match().node(labels='Person', ref_name='q').related_to('friend_of').node(ref_name='p')
query = query1 + query2
print(query)
This snippet will output the following Cypher query:
cypher
MATCH (p: Person) WITH p MATCH (q: Person)-[: friend_of]->(p)
Prerequisites
- Python 3.8+
Contributing
Intro
We encourage you to help us to improve this package! These instructions will give you a copy of the project up and running on your local machine for development and testing purposes.
Installing a Development Environment
```shell
Set virtual environment.
python -m venv .venv source .venv/bin/activate
Upgrade pip
Install development dependencies.
Tools needed for deployment and packaging will be installed now.
pip install -r requirements-dev.txt ```
Development tools configurations
setuptoolsis configured insetup.cfgpycodestyleis configured insetup.cfgcoverage.pyis configured inpyproject.toml
Testing
pytest is used as a test runner.
pytest configurations reside in pyproject.toml
pytest fixtures are stored in tests/conftest.py file.
How-to run tests:
```shell
Install test requirements.
pip install -r requirements-test.txt
Run tests.
All the tests under tests/ directory will be run.
pytest --cov=cymple
```
Adding a new Cypher clause
Adding a new Cypher clause to Cymple consists of few simple steps:
1. Go to src/cymple/internal/declarations/. This directory contains all supported clause declarations.
2. Add a json file describing the clause and the method(s) interfaces(s) of the new clause that you would like to add to the builder. If you do it for the first time, take a look at existing json files of currently supported Cypher clauses.
3. Identify all the existing clauses that can precede your new clause, and add your new clause's name to the 'successors' list of those clauses' JSONs.
4. Run python src/cymple/internal/internal_renderer.py. This script generates a new builder.py file with all clauses that were declared in src/cymple/internal/declarations/.
5. By default, by adding a declaration json file, the internal_builder.py script takes the declared clause and generates a method that simply concatenates your new clause to the builder's current query. However, if you need anything more complex than that, you can write your own implementation by creating a new method with your clause's name at src/cymple/internal/overloads/. Don't forget to run python src/cymple/internal/internal_renderer.py again :)
6. If you're satisfied with the new clause, add a unit test in test_clauses.py and make sure it generates the expected Cypher string.
Generating Documentation
Make sure you run:
pip install -r requirements-dev.txt
or
pip install sphinx
to proceed.
To generate a new HTML documentation, run:
cd docs
make clean html
make html
Versioning
Semantic Versioning is used for versioning.
For the versions available, see the tags on the repository.
Current version is stored in src/cymple/version.py.
Project structure
```shell cymple/ ├── docs/ # Project documentation ├── pyproject.toml # Development and packaging tools configurations ├── README.md # Project general information ├── requirements-dev.txt # Development dependencies, such as packaging tools, etc. ├── requirements-test.txt # Test dependencies ├── requirements.txt # Pinned versions of all the end-user dependency tree ├── setup.cfg # packaging tool configurations ├── setup.py # Packaging script ├── src/ # All source code │ └── cymple/ # Cymple source code │ ├── internal/ # Cypher builder internal renderer │ │ ├── declarations/ # clause declarations │ │ ├── overloads/ # custom clause implementations │ │ ├── finale.py # A part of the rendered code that comes last │ │ ├── internalrenderer.py # Internal renderer implementation for creating Cymple's user-facing code │ │ └── preface.py # A part of the rendered code that comes first │ ├── _init.py # Package initialization │ ├── __main.py # Main script when run as a command line tool │ ├── builder.py # Query Builder implementation │ ├── typedefs.py # Query Builder typedefs to be used in Cymple's API │ └── version.py # Package version └── tests/ # Tests ├── conftest.py # Fixtures ├── data/ # Tests data files, such as input/output files, mocks, etc. ├── e2e/ # End-to-End functional tests ├── integration # Integration tests └── unit # Unit tests ├── init.py └── testrealuse_cases.py # Test project startup
```
Owner
- Name: Accenture
- Login: Accenture
- Kind: organization
- Website: https://accenture.github.io
- Repositories: 185
- Profile: https://github.com/Accenture
Accenture Github site
GitHub Events
Total
- Issues event: 3
- Watch event: 9
- Issue comment event: 6
- Push event: 3
- Pull request review event: 2
- Pull request event: 7
- Fork event: 2
- Create event: 2
Last Year
- Issues event: 3
- Watch event: 9
- Issue comment event: 6
- Push event: 3
- Pull request review event: 2
- Pull request event: 7
- Fork event: 2
- Create event: 2
Committers
Last synced: 9 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| roei.levi | r****i@a****m | 87 |
| yaelzamir | y****r@a****m | 21 |
| dependabot[bot] | 4****] | 1 |
| Varsius | v****r@o****e | 1 |
| Amon Khavari | a****i@v****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 5 months ago
All Time
- Total issues: 7
- Total pull requests: 41
- Average time to close issues: 19 days
- Average time to close pull requests: 3 days
- Total issue authors: 7
- Total pull request authors: 7
- Average comments per issue: 1.14
- Average comments per pull request: 0.22
- Merged pull requests: 31
- Bot issues: 0
- Bot pull requests: 6
Past Year
- Issues: 4
- Pull requests: 9
- Average time to close issues: about 1 month
- Average time to close pull requests: 4 days
- Issue authors: 4
- Pull request authors: 5
- Average comments per issue: 0.25
- Average comments per pull request: 0.33
- Merged pull requests: 4
- Bot issues: 0
- Bot pull requests: 2
Top Authors
Issue Authors
- TechInTerh (1)
- danjhd (1)
- Varsius (1)
- Tot-ziens (1)
- andy-k-improving (1)
- NOT-HAL9000 (1)
- Claus1 (1)
Pull Request Authors
- Yael-Zamir (18)
- Roei-Levi (12)
- dependabot[bot] (6)
- andy-k-improving (2)
- iamkhav (1)
- Varsius (1)
- pcadmanbosse (1)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- autopep8 ==1.6.0 development
- flake8 ==4.0.1 development
- pip-tools ==6.6.0 development
- pycodestyle ==2.8.0 development
- pydocstyle ==6.1.1 development
- pylint ==2.13.5 development
- setuptools ==62.0.0 development
- sphinx ==4.5.0 development
- sphinx-rtd-theme ==1.0.0 development
- wheel ==0.37.1 development
- pytest ==7.1.1 test
- pytest-cov ==3.0.0 test
- actions/checkout v3 composite
- actions/setup-python v4 composite
- pypa/gh-action-pypi-publish release/v1 composite