A small example DSL using gremlinpython
Project description
gremlin-dsl
A small example Gremlin DSL for the toy Modern database.
About
There aren't many complete examples of building a domain specific language (DSL) using the Gremlin Python driver. This is a small example Python package that implements a DSL for the Modern toy database, served using the Gremlin Server.
Usage Notes
The first necessary step is to install the Gremlin server:
$ curl -o gremlin-server.zip https://dlcdn.apache.org/tinkerpop/3.6.0/apache-tinkerpop-gremlin-server-3.6.0-bin.zip
$ unzip gremlin-server.zip
$ rm -rf gremlin-server.zip
The link for the latest release of the Gremlin Server can be found here.
Next, start the server with the Modern config:
$ cd apache-tinkerpop-gremlin-server-3.6.0/
$ bin/gremlin-server.sh conf/gremlin-server-modern.yaml
Docs on using the Gremlin Server can be found here.
The package can then be installed from PyPi:
$ pip install gremlin-dsl
With the server running, you can use to the DSL to write queries against the Modern database:
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
from gremlin_python.process.anonymous_traversal import traversal
from gremlin_dsl.core_dsl import get_db_endpoint
from gremlin_dsl.core_dsl import SocialTraversalSource
def main():
endpoint = get_db_endpoint()
connection = DriverRemoteConnection(endpoint, "g")
social = traversal(SocialTraversalSource).with_remote(endpoint)
print(social.persons("marko").knows("josh"))
connection.close()
if __name__ == "__main__":
main()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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
File details
Details for the file gremlin-dsl-0.3.0.tar.gz.
File metadata
- Download URL: gremlin-dsl-0.3.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.14 CPython/3.8.3 Darwin/21.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e93ec411c0ac4f6e0e1122fc5234ccb2c3c653e4e1f8c8e79dfc474c4451fe34
|
|
| MD5 |
fe0b05b2016faea4798a17c7777d2e69
|
|
| BLAKE2b-256 |
84e40268e5ae5a1dc0770e02634fda874d69caa611d8fe6ca25b04e74576a2b5
|
File details
Details for the file gremlin_dsl-0.3.0-py3-none-any.whl.
File metadata
- Download URL: gremlin_dsl-0.3.0-py3-none-any.whl
- Upload date:
- Size: 3.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.14 CPython/3.8.3 Darwin/21.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cea2e3a2447f87f307017e502abdc3b9b327e508e495d658c4078b10575bf695
|
|
| MD5 |
cc581f8e6050cedaf7525355a81c4bf7
|
|
| BLAKE2b-256 |
7bc604e4891a5f5113a8f67fca59b3d9c51107ebbfee25e13f06f9771f6f500c
|