-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathtest_cypher.py
More file actions
executable file
·25 lines (17 loc) · 786 Bytes
/
test_cypher.py
File metadata and controls
executable file
·25 lines (17 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python3
"""
Talking to JanusGraph from Python.
http://tinkerpop.apache.org/docs/current/reference/#gremlin-python
"""
from gremlin_python.driver.client import Client
from gremlin_python.driver.request import RequestMessage
from gremlin_python.driver.serializer import GraphSONMessageSerializer
TRAVERSAL_SOURCE = 'g'
serializer = GraphSONMessageSerializer()
# workaround to avoid exception on any opProcessor other than `standard` or `traversal`:
serializer.cypher = serializer.standard
client = Client('ws://localhost:8182/gremlin', TRAVERSAL_SOURCE, message_serializer=serializer)
cypherQuery = "MATCH (n:airport) RETURN n.desc"
message = RequestMessage('cypher', 'eval', {'gremlin': cypherQuery})
results = client.submit(message).all().result()
print(results)