我正在嘗試使用來自 EC2 實體的 Python 連接到 Neptune。
蟒蛇代碼:
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 query 。它的輸出原樣
輸出:
[['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]]
uj5u.com熱心網友回復:
Gremlin 查詢是惰性求值的,因此您必須在查詢中添加一個終端步驟,以便服務器執行它。如果您更改您的行以添加如下所示的這些步驟之一,那么它將由服務器執行。
print(g.V().has("system.tenantId", "sample_tenantId").count().next())
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/329548.html
