简体   繁体   English

py2neo关系不可调用错误

[英]py2neo Relationship not callable error

I am using py2neo REST API to connect to neo4j version 1.9.5 via a Mac. 我正在使用py2neo REST API通过Mac连接到neo4j 1.9.5版。 I have successfully created three nodes: a, b and c using graph_db.create() . 我已经使用graph_db.create()成功创建了三个节点:a,b和c。 Then I successfully created a relationship "MANAGES" between a and b using: rel, = graph_db.create(rel((a, "MANAGES",b))) . 然后,我成功使用以下方法在a和b之间创建了一个关系“ MANAGES”: rel, = graph_db.create(rel((a, "MANAGES",b))) However, when I try to create a "MANAGES" relationship between a and c, using rel2, = graph_db.create(rel((a, "MANAGES",c))) , I get the following error: 但是,当我尝试使用rel2, = graph_db.create(rel((a, "MANAGES",c)))在a和c之间创建“ MANAGES”关系时,出现以下错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'Relationship' object is not callable

I have not created any indexes for the nodes or relationships. 我尚未为节点或关系创建任何索引。 Could that be the problem? 这可能是问题吗? Presumably there is no problem assuming a data model where a node may have many relationships of the same type with other nodes. 假设一个节点可能与其他节点具有许多相同类型的关系的数据模型,大概没有问题。

Thanks. 谢谢。

What you've accidentally done there is to override the py2neo function rel with you own relationship variable: 您不小心所做的就是使用您自己的关系变量覆盖py2neo函数rel

rel, = graph_db.create(rel((a, "MANAGES",b)))
 ^                      ^
 |                      |
this             overwrites this

So the easy fix is to pick another name: 因此,简单的解决方法是选择另一个名称:

ab, = graph_db.create(rel((a, "MANAGES",b)))

After that, your subsequent call should work. 在那之后,您的后续呼叫应该起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM