dse 图 python - 没有这样的 属性: g for class: 错误

dse graph python - No such property: g for class: error

我是 dse 图表的新手。我遇到错误

No such property: g for class: error

我做错了什么?

>>> from dse.cluster import Cluster, EXEC_PROFILE_GRAPH_SYSTEM_DEFAULT, GraphExecutionProfile
>>> from dse.graph import GraphOptions
>>> from dse.auth import PlainTextAuthProvider
>>> Auth_provider = PlainTextAuthProvider(username=<<username>>,
    password=<<password>>)
>>> ep = GraphExecutionProfile(graph_options=GraphOptions(graph_name='idg'))
>>> cluster = Cluster(database_cluster, auth_provider=auth_provider,
     execution_profiles={EXEC_PROFILE_GRAPH_SYSTEM_DEFAULT: ep})
>>> dse_session.execute_graph('g.V()')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "dse/cluster.py", line 2017, in dse.cluster.Session.execute_graph
  File "dse/cluster.py", line 3962, in dse.cluster.ResponseFuture.result
dse.InvalidRequest: Error from server: code=2200 [Invalid query] message="No such property: g for class: Script184"

>>> print(vars(ep.graph_options))
{'_graph_options': {'graph-name': b'idg', 'graph-source': b'g', 'graph-language': b'gremlin-groovy', 'graph-results': b'graphson-1.0'}}

在定义执行配置文件时,您需要使用 EXEC_PROFILE_GRAPH_DEFAULT 而不是 EXEC_PROFILE_GRAPH_SYSTEM_DEFAULTEXEC_PROFILE_GRAPH_SYSTEM_DEFAULT 用于访问系统 API 以操作图表等

您还需要通过 session = cluster.connect() 连接到集群(我在您的代码中没有看到它)。

请参阅 more examples 的驱动程序文档。

现在有效。在我使用 EXEC_PROFILE_GRAPH_DEFAULT 作为执行配置文件后

>>> from dse.cluster import Cluster, EXEC_PROFILE_GRAPH_DEFAULT, GraphExecutionProfile
>>> from dse.graph import GraphOptions,SimpleGraphStatement
>>> from dse.auth import PlainTextAuthProvider
>>> Auth_provider = PlainTextAuthProvider(<<username>>, <<password>>)
>>> ep = GraphExecutionProfile(graph_options=GraphOptions(graph_name='idg'))
>>> cluster = Cluster(database_cluster, auth_provider=auth_provider, execution_profiles={EXEC_PROFILE_GRAPH_DEFAULT: ep})
>>> dse_session = cluster.connect()
>>> dse_session.execute_graph('g.V()')
<dse.cluster.ResultSet object at 0x10f1fbef0>