簡體   English   中英

neo4j - py2neo - 無法在創建時將參數放入關系中

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

如果我在 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()

但是,當我嘗試向關系添加參數時...:

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()

我懂了:

    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

我如何放置這些變量以避免這些錯誤? 提前致謝。

參數不能用於屬性名稱、關系類型和標簽:( 鏈接,

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM