我正在尝试从 Python 代码内部对 AWS Neptune 数据库运行 Gremlin 查询,并希望将返回的数据存储到 Python 列表中。这对于简单的 Gremlin 查询工作正常,但一些更复杂的查询似乎有问题。
下面是代码,第一个 Gremlin 查询工作正常,但第二个不行。该节点不存在,因此可以在不导入任何数据的情况下进行尝试。
from __future__ import print_function # Python 2/3 compatibility
from gremlin_python import statics
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
graph = Graph()
remoteConn = DriverRemoteConnection('wss://sdm-neptune-db-instance-1.cduuicw2rgrv.us-east-1.neptune.amazonaws.com:8182/gremlin','g')
g = graph.traversal().withRemote(remoteConn)
cust_List=g.V('AZ50K115E39AX').hasLabel('tp21tpcust').count().toList()
for p in cust_List:
print('Data Fetched: ' + str(p))
cust_List=g.V('XXXXXXXX').hasLabel('tp21tpcust').local(__.repeat(__.out().simplePath()).until(__.not_(__.out())).path().by(id).limit(100)).local(__.unfold().union(__.limit(1),__.tail()).fold()).dedup().toList()
for p in cust_List:
print('Data Fetched' + p)
remoteConn.close()
Run Code Online (Sandbox Code Playgroud)
这是错误,任何指导将不胜感激
Data Fetched: 1
Traceback (most recent call …Run Code Online (Sandbox Code Playgroud)