I am trying to use an AWS Lambda function w/ Python 3.7 to access my Neptune DB. For a very simple test, I have the following code in my lambda.
g = graph.traversal().withRemote(DriverRemoteConnection('ws://[endpoint]:8182/gremlin','g'))
g.addV('student').property('name', 'Jeffery').property('GPA', 4.0)
students = g.V('student').values('name')
print(numVert)
After trying many different traversals the only value I get from the print statement is
[['V', 'student'], ['values', 'name']]
or some similar list representation of the commands I want to execute instead of the data itself (like Jeffrey).
Am I missing some obvious error? I have tried specifying how I want my result with toList which does not help. Thanks!
When using Gremlin from code you need to always end your query with a terminal step such as toList
, next
or iterate
etc. What you are seeing is just the byte code "to string" form of your query/traversal as the query was not actually executed due to the lack of a terminal step. You also need to use hasLabel
when you search for the students. The V()
step takes an optional list of one or more IDs not a label.
g.addV('student').property('name', 'Jeffery').property('GPA', 4.0).next()
students = g.V().hasLabel('student').values('name').toList()
print(students)
Here is your query run using Gremlin Python
>>> g.addV('student').property('name', 'Jeffery').property('GPA', 4.0).next()
v[9eb98696-d979-c492-ab2d-a36a219bac6c]
>>> students = g.V().hasLabel('student').values('name').toList()
>>> print(students)
['Jeffery']