如何在python gremlin中检索顶点的属性值

2024-06-16 09:46:35 发布

您现在位置:Python中文网/ 问答频道 /正文

这可能很容易,但我真的在努力解决这个问题。我使用gremlin python lib和aws neptune db。 我知道顶点id,我只想得到顶点的一个属性的值(python中的字符串类型),并更新它。你知道吗

我试过这样做:

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

但是我只打印了一些python gremlin对象,比如GraphTraversal,无法将值检索为string

有人能帮我吗?你知道吗


Tags: 字符串awseventid类型db属性lib
1条回答
网友
1楼 · 发布于 2024-06-16 09:46:35

必须使用终端步骤,否则查询将无法执行。你知道吗

来自tinkerpopdocumentation

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.

在您的情况下,您应该:

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

相关问题 更多 >