g2c is a python script to convert Gremlin query to Cypher query with OpenAI API
Project description
g2c
Overview
g2c is a python script to convert Gremlin query to Cypher query with OpenAI API
Table of Contents
Installation
Just add tap and install homebrew package.
brew tap rioriost/g2c
brew install g2c
Prerequisites
- Python 3.11 or higher
- OpenAI API key enabled to call gpt-4o-mini
Usage
Execute g2c command.
g2c --help
usage: g2c [-h] (-g GREMLIN | -f FILEPATH | -u URL)
Convert Gremlin queries to Cypher queries.
options:
-h, --help show this help message and exit
-g GREMLIN, --gremlin GREMLIN
The Gremlin query to convert.
-f FILEPATH, --filepath FILEPATH
Path to the source code file (.py, .java, .cs, .txt)
-u URL, --url URL URL to the source code file (.py, .java, .cs, .txt)
The indentical usage is shown below.
with -g(--gremlin)
g2c -g 'g.V().has(“name”, “Alice”).as(“a”).V().has(“name”, “Bob”).as(“b”).select(“a”, “b”).by(“name”)'
Converted Cypher queries:
line 1, g.V().has("name", "Alice").as("a").V().has("name", "Bob").as("b").select("a", "b").by("name") ->
MATCH (a {name: "Alice"}), (b {name: "Bob"}) RETURN a.name AS a, b.name AS b
with -u(--url)
g2c --url https://raw.githubusercontent.com/nedlowe/gremlin-python-example/refs/heads/master/app.py
Converted Cypher queries:
line 42, g.V(person_id).toList() ->
MATCH (p) WHERE id(p) = person_id RETURN p
line 42, g.V(person_id) ->
MATCH (n) WHERE id(n) = person_id RETURN n
line 55, g.V(vertex).valueMap().toList() ->
MATCH (n) WHERE id(n) = $vertex RETURN n
line 55, g.V(vertex).valueMap() ->
MATCH (n) WHERE id(n) = $vertex RETURN n
line 55, g.V(vertex) ->
MATCH (n) WHERE id(n) = vertex RETURN n
line 77, g.addV('person').property(T.id, person_id).next() ->
CREATE (n:person {id: person_id})
......
with -f(--filepath)
g2c --file ~/Desktop/g.py
Converted Cypher queries:
line 1, "g.V()" ->
MATCH (n) RETURN n
line 3, "g.E()" ->
MATCH ()-[r]->() RETURN r
line 4, "g.V('vertexId')" ->
MATCH (n) WHERE id(n) = 'vertexId' RETURN n
......
Release Notes
0.2.0 Release
- Changed the default behaviour to accept a Gremlin query (-g), a file (-f), or a URL (-u).
- Added feature to extract Gremlin queries from a file or URL.
- Added CacheManager and a feature to deploy a cache file to user home directory if it doesn't exist.
0.1.0 Release
- Initial release.
License
MIT License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
g2c-0.2.0.tar.gz
(8.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
g2c-0.2.0-py3-none-any.whl
(9.3 kB
view details)
File details
Details for the file g2c-0.2.0.tar.gz.
File metadata
- Download URL: g2c-0.2.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.27
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dc9d2c3e708ad8076087498d619508683c15c3035f9b62cf45167bd31eab932
|
|
| MD5 |
8e24d5833da5c1b9925c354a20f139de
|
|
| BLAKE2b-256 |
5a29237484a02d2e19b1c82c9371afb9c40a8a48f40fb56c0448c9a1818e1c01
|
File details
Details for the file g2c-0.2.0-py3-none-any.whl.
File metadata
- Download URL: g2c-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.27
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e86eac751440e8e242b245f970a7376b65625c1284e8c11d13467c58ffdf5223
|
|
| MD5 |
12bbf0929730d4f54f9c46d90d25edb2
|
|
| BLAKE2b-256 |
79d2209dcb72c4ec842b305b74c471d5bcf33f610fbf20990db7825c8cfef02a
|