【发布时间】:2021-05-03 22:45:27
【问题描述】:
概要
我正在尝试在与 Amazon Neptune 实例位于同一 VPC 中的 Amazon EC2 实例上使用 Python 向 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 列表。
预期行为
- 对
conn.addV()的调用会引发异常,或者... -
conn.addV()调用成功,print()行返回顶点
问题:如何在 Amazon Neptune 中使用适用于 Python 的 Gremlin 模块向图中添加顶点?
【问题讨论】:
标签: python amazon-web-services tinkerpop amazon-neptune