【问题标题】:How to connect to AWS Neptune (graph database) with Python?如何使用 Python 连接到 AWS Neptune(图形数据库)?
【发布时间】:2019-08-14 20:26:29
【问题描述】:

我正在学习本教程:

https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-python.html

如何添加节点然后检索相同的节点?

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

print(g.V().limit(2).toList())
remoteConn.close()

上面现在所做的只是检索 2 个节点,对吗?

【问题讨论】:

  • 问题不清楚。您是否设法连接到 Neptune 并运行查询?如果没有,您能否提供有关您收到的错误消息的更多信息。

标签: amazon-neptune


【解决方案1】:

如果您想添加一个顶点,然后返回有关该顶点的信息(假设您没有提供自己的 ID),您可以执行类似的操作

newId = g.addV("mylabel").id().next()

【讨论】:

    猜你喜欢
    • 2021-05-15
    • 2019-06-04
    • 2020-10-18
    • 2021-12-07
    • 2019-08-10
    • 2019-03-08
    • 2019-05-03
    • 1970-01-01
    • 2021-12-02
    相关资源
    最近更新 更多