Skip to main content

g2c is a python script to convert Gremlin query to Cypher query with OpenAI API

Project description

g2c

License

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

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.1.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

g2c-0.2.1-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file g2c-0.2.1.tar.gz.

File metadata

  • Download URL: g2c-0.2.1.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.27

File hashes

Hashes for g2c-0.2.1.tar.gz
Algorithm Hash digest
SHA256 d96dc1e6368308655040b46a7be9989a736360d3dedfc54a9cc8016d8ec2a3b7
MD5 86481bcc0fb3e77e9e33859aed4c972d
BLAKE2b-256 09038412243a8d1eaedb2301fee218250ee212d18d5a1d7b20f8b8e8a410879f

See more details on using hashes here.

File details

Details for the file g2c-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: g2c-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.27

File hashes

Hashes for g2c-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f7eab1d3355c7683ee5d2e380d86abb78b6913f75013ee18bbfae36e1b279c8d
MD5 8efd394d7e33f0bf8e9da1d649769bc6
BLAKE2b-256 f7d3d4c971cca2ce939938d940e6b8663b087e45ef6a2c460e7862ceef5ab40c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page