我尝试根据节点编号进行查询并返回属性列表。以下cypher查询在neo4j浏览器中有效,但当我尝试通过py2neo传递相同的密码查询时,我得到:
"Expected a property container or number here, but got:91"
其中" 91"是我查询的节点号。
摘自我的代码:
def neighbor_finder(a):
try:
graph_db = neo4j.GraphDatabaseService(url)
query = neo4j.CypherQuery(graph_db,
"""CYPHER 2.0
MATCH (n)-[r]-(m)
WHERE ID(n) = {t}
WITH collect (Distinct m.size) as sizes, collect (Distinct m.weight) as weights, collect (Distinct m.color) as colors, collect (distinct n.label) as node_
RETURN sizes, weights, colors, node_
""")
result = query.execute(t=a)
for r in result:
column = [str(item) for item in r.columns]
value = [str(item) for item in r.values]
db_dict={k: v for k, v in zip(column, value)}
for x, y in db_dict.items():
print x, y
except Exception as e:
print e
答案 0 :(得分:1)
您能否提供传递给此函数的a
参数的类型和值的详细信息?没有它,我无法看到py2neo传递给查询参数的内容。
答案 1 :(得分:0)
参数“a”未被读取,因为它需要声明为整数,cypher / py2neo当前正在将其作为字符串读取。