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.2.tar.gz (104.0 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.2-py3-none-any.whl (102.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for g2c-0.2.2.tar.gz
Algorithm Hash digest
SHA256 2aedf13d04d25946770071aed0a9bd61ea78ff55100563a72462ba0dd817bc74
MD5 8b118f95e78d0d8d3b975903d81678b4
BLAKE2b-256 a67da8a8ecf822dddd6ea4b158a9f259cf9ff5c995169b38f2fd214ca007be5c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for g2c-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3fc788d7cf8e888d7d0860fcb3858cc75f37935529ce6a8d39ab201d3993370c
MD5 30b5a76198f1e75da0539bc92e906768
BLAKE2b-256 eca44cefff4271b12498b8aa54c622f28cc6ae51bc6ce76b09bcf4704bec5873

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