如何在 py2neo 中使用 graph.pull?
how to use graph.pull in py2neo?
在我的代码中,我使用 py2neo 创建带有标签 foobar 的对象。
如果我想从数据库中提取其中一些,它 returns:
None
代码(注意数据库中已经有foobar对象):
class foobar(GraphObject):
__primarykey__ = "name"
name = Property()
#... graph initialized etc.
foo = foobar()
foo.name = "bar"
foo = graph.pull(foo) #get all foobar data from graph
print(foo)
None
来自doc:
Graph.pull(graph_object): Update a GraphObject and its associated
RelatedObject instances with changes from the graph.
所以如果你想从图表中获取数据,也许你应该先创建或推送你的对象到图表?如果你想检索现有对象,你必须先 select 它
foobar.select(graph).where("_.name = 'bar'").first()
在我的代码中,我使用 py2neo 创建带有标签 foobar 的对象。 如果我想从数据库中提取其中一些,它 returns:
None
代码(注意数据库中已经有foobar对象):
class foobar(GraphObject):
__primarykey__ = "name"
name = Property()
#... graph initialized etc.
foo = foobar()
foo.name = "bar"
foo = graph.pull(foo) #get all foobar data from graph
print(foo)
None
来自doc:
Graph.pull(graph_object): Update a GraphObject and its associated RelatedObject instances with changes from the graph.
所以如果你想从图表中获取数据,也许你应该先创建或推送你的对象到图表?如果你想检索现有对象,你必须先 select 它
foobar.select(graph).where("_.name = 'bar'").first()