AttributeError:“事务”对象没有属性“append”

2024-10-01 17:30:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我开始使用Py2neo和Neo4j来启动它们之间的连接,并且已经正确地安装了这两个库,没有任何错误。当我决定通过以下命令开始训练时:

from py2neo import Graph
graph = Graph("bolt://localhost:7687", user="neo4j", password="mypass")
tx = graph.begin()
for name in ["Mohammad", "Ahmad", "Dad", "Mom"]:
    tx.append("CREATE (person:Person {name:{name}}) RETURN person", name=name)
Mohammad, Ahmad, Dad, Mom = [result.one for result in tx.commit()]

出现错误:

^{pr2}$

有没有解决方法可以消除这个错误,append属性是否在py2neo中过期并被一个新的替换?在


Tags: nameinfor错误resultgraphpersontx
1条回答
网友
1楼 · 发布于 2024-10-01 17:30:12

不要使用append。 首先,您需要创建一个节点,这可以通过以下方式实现:

tx = graph.begin()
a = Node("linkedinn",name="random")
tx.create(a) 
tx.commit()

这样就可以在图形中创建一个节点。现在我真的不知道为什么append不起作用,我也有同样的问题。在

相关问题 更多 >

    热门问题