Search code examples
pythongremlinamazon-neptunegremlinpython

How to retrieve a property value of a vertex in python gremlin


It might be easy, but I am really struggling with this problem. I use gremlin python lib and aws neptune db. I know the vertex id, I just want to get the value(String type in python) of one of the properties of the vertex, and update it.

I have tried to do like this:

print(g.V(event['securityEventManagerId']).values('sourceData'))
print(g.V(event['securityEventManagerId']).property('sourceData'))
print(g.V(event['securityEventManagerId']).property('sourceData').valueMap())
.....

But I just print some python gremlin object like GraphTraversal, cannot retrieve the value as a string

Can anyone help me out?


Solution

  • You must use a terminal step, without them your query will not execute.

    From tinkerpop documentation:

    Typically, when a step is concatenated to a traversal a traversal is returned. In this way, a traversal is built up in a fluent, monadic fashion. However, some steps do not return a traversal, but instead, execute the traversal and return a result. These steps are known as terminal steps (terminal) and they are explained via the examples below.

    In your case, you should do:

    g.V(event['securityEventManagerId']).values('sourceData').next()