py2neo 引发完成(自我)错误 [英] py2neo raised finished(self) error
本文介绍了py2neo 引发完成(自我)错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 py2neo 时,我在尝试追加交易时收到以下错误:
Working with py2neo and I'm getting the error below when trying to append a transaction:
statement ="MERGE (a:Person {name:\""+actorName+"\"}) "\
"\n"\
"MERGE (b:Series {title:\""+actorsFields[3]+"\", year:\""+actorsFields[5]+"\"}) "\
"\n"\
"CREATE UNIQUE (a)-[:ACTED_IN]->(b)"\
"RETURN a,b"
print(statement)
tx.append(statement)
回溯是:
Traceback (most recent call last):
File "/Volumes/PyCharm CE/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 2222, in <module>
globals = debugger.run(setup['file'], None, None)
File "/Volumes/PyCharm CE/PyCharm CE.app/Contents/helpers/pydev/pydevd.py", line 1648, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Users/Thibault/PycharmProjects/movieGraph/src/mainCypher.py", line 110, in <module>
tx.append(statement)
File "/Library/Python/2.7/site-packages/py2neo/cypher/core.py", line 220, in append
self.__assert_unfinished()
File "/Library/Python/2.7/site-packages/py2neo/cypher/core.py", line 192, in __assert_unfinished
raise Finished(self)
py2neo.error.Finished
有什么想法吗?
推荐答案
如果你两次调用 tx.commit() 而没有 tx = graph.cypher.begin() ,你会得到这个错误.如果您试图对提交进行分块,这是一个容易犯的错误.更明确地说:
You will get this error if you call tx.commit() twice without a tx = graph.cypher.begin() in between. This is an easy mistake to make if you are trying to chunk your commits. To be more explicit:
#This will give the above error
tx = graph.cypher.begin()
for i in range(0,10):
tx.append(statement="foo",parameters=bar)
tx.commit()
#This will work fine
for i in range(0,10):
tx = graph.cypher.begin()
tx.append(statement="foo",parameters=bar)
tx.commit()
这篇关于py2neo 引发完成(自我)错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文