简体   繁体   English

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

[英]neo4j - py2neo - Unable to place parameters into relationship on creation

If I run my python script over neo4j database, works ok:如果我在 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()

but, when I tried to add parameters to relationship...:但是,当我尝试向关系添加参数时...:

a=raw_input("Input Name A: ")
b=raw_input("Input Name B: ")
z=raw_input("Input parameter of relationship z: ")
x=raw_input("Input parameter of relationship x: ")
graph = Graph()
tx = graph.cypher.begin()
tx.append("MATCH (c:Person {name:{a}}), (d:Person {name:{b}}) CREATE (c)-[:KNOWS{labelz:{z},labelx:{x}}]->(d)", a=a, b=b)
tx.commit()

I got this:我懂了:

    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

How do I have to place those variables to avoid that errors?我如何放置这些变量以避免这些错误? Thanks in advance.提前致谢。

Parameters can not be used as for property names, relationship types and labels:( link ,参数不能用于属性名称、关系类型和标签:( 链接,

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

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