如何解决使用 Python 的 gremlin 模块将顶点添加到 Amazon Neptune 图数据库 概要实际行为预期行为
概要
我尝试在 Amazon EC2 实例上使用 Python,在与 Amazon Neptune 实例相同的 VPC 中,将顶点(节点)添加到 Neptune。使用 example code for Amazon Neptune,我构建了以下代码示例来添加一个顶点(节点),然后打印出图中的所有顶点。
from gremlin_python import statics
from gremlin_python.process.anonymous_traversal import traversal
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
from gremlin_python.structure.graph import Graph
from pprint import pprint
target = 'zzzzzz-instance-1.zzzzzzzz.us-west-2.neptune.amazonaws.com'
port = '8182'
g = Graph()
remote = DriverRemoteConnection(f'wss://{target}:{port}/gremlin','g')
conn = g.traversal().withRemote(remote)
conn.addV('person').property(id,5).property('firstname','Trevor')
print(conn.V().toList())
实际行为
对 conn.addV()
的调用静默失败,带有 print()
语句的以下行返回一个空的 Python 列表。
预期行为
问题:如何在 Amazon Neptune 中使用 Python 的 Gremlin 模块向图中添加顶点?
解决方法
您的 addV() 查询需要一个终端步骤,例如 next() 或 iterate()。否则,您将获得返回查询的字节码表示。 http://www.kelvinlawrence.net/book/PracticalGremlin.html#var
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。