Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python neo4j-py2neo-无法在创建时将参数放入关系中_Python_Neo4j_Cypher_Py2neo - Fatal编程技术网

Python neo4j-py2neo-无法在创建时将参数放入关系中

Python neo4j-py2neo-无法在创建时将参数放入关系中,python,neo4j,cypher,py2neo,Python,Neo4j,Cypher,Py2neo,如果我在neo4j数据库上运行python脚本,工作正常: from py2neo import Node, Relationship, Graph, cypher, authenticate # set up authentication parameters authenticate("localhost:7474", "user", "password") # connect to authenticated graph database sgraph = Graph("http://

如果我在neo4j数据库上运行python脚本,工作正常:

from py2neo import Node, Relationship, Graph, cypher, authenticate # set up authentication parameters authenticate("localhost:7474", "user", "password") # connect to authenticated graph database sgraph = Graph("http://localhost:7474/db/data/") a=raw_input("Input Name A: ") b=raw_input("Input Name B: ") graph = Graph() tx = graph.cypher.begin() tx.append("MATCH (c:Person {name:{a}}), (d:Person {name:{b}}) CREATE (c)-[:KNOWS}]->(d)", a=a, b=b) tx.commit() 我明白了:

tx.commit() File "/usr/local/lib/python2.7/dist-packages/py2neo/cypher/core.py", line 333, in commit return self.post(self.__commit or self.__begin_commit) File "/usr/local/lib/python2.7/dist-packages/py2neo/cypher/core.py", line 288, in post raise self.error_class.hydrate(error) py2neo.cypher.error.statement.ParameterMissing: Expected a parameter named z 我必须如何放置这些变量以避免错误?
提前感谢。

参数不能用作属性名称、关系类型 和标签:

您在查询结束时提供了a和b的参数,但没有提供z或x。你完全正确,几分钟前我就可以测试了。抱歉打扰了。但我尝试做的另一件事是将关系的标签作为参数引入,在本例中,它知道,甚至在查询结束时也不起作用。在本例中,使用字符串连接将关系类型动态添加到查询中可能是一个好主意。或者,如果安装了APOC过程,则可以使用来创建关系,而不是使用create。这将允许您为关系类型提供一个字符串。 tx.commit() File "/usr/local/lib/python2.7/dist-packages/py2neo/cypher/core.py", line 333, in commit return self.post(self.__commit or self.__begin_commit) File "/usr/local/lib/python2.7/dist-packages/py2neo/cypher/core.py", line 288, in post raise self.error_class.hydrate(error) py2neo.cypher.error.statement.ParameterMissing: Expected a parameter named z