【问题标题】:Python - connecting to Neptune using gremlinPython - 使用 gremlin 连接到 Neptune
【发布时间】:2021-12-07 13:10:31
【问题描述】:

我正在尝试使用 Python 从 EC2 实例连接到 Neptune。

Python 代码:

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://my_end_point:8182/gremlin','g')
g = graph.traversal().withRemote(remoteConn)

print(g.V().has("system.tenantId", "sample_tenantId").count())
remoteConn.close()

而不是执行 gremlin 查询。它按原样给出输出

输出:

    [['V'], ['has', 'system.tenantId', 'sample_tenantId'], ['count']]

问题:为什么它不接受 gremlin 查询?

请注意: 连接正确,我得到了链接中提到的输出:https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-python.html

output:    [v[sample_RETURN_D_H], v[sample_IND]] 

【问题讨论】:

    标签: python amazon-web-services gremlin amazon-neptune


    【解决方案1】:

    Gremlin 查询是惰性求值的,因此您必须在查询中添加 terminal step 才能让服务器执行它。如果您更改您的行以添加如下所示的这些步骤之一,那么它将由服务器执行。

    print(g.V().has("system.tenantId", "sample_tenantId").count().next())
    

    【讨论】:

      猜你喜欢
      • 2019-06-04
      • 2019-08-10
      • 1970-01-01
      • 2021-12-30
      • 1970-01-01
      • 1970-01-01
      • 2021-12-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多