py2neo引发了finished(self)错误。

3
使用py2neo工具时,尝试追加事务时出现以下错误:
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

有什么想法吗?

1
你解决了这个问题吗? - NumenorForLife
1
不,最终我使用了批量文件上传功能...这很好用,因为我目前不需要频繁更新,但在某个时候我需要重新开始使用它! - Thibault Lefevre
1个回答

2
如果在tx = graph.cypher.begin()之间两次调用tx.commit(),则会出现此错误。如果你试图分块提交,那么很容易犯这个错误。更明确地说:
 #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()

虽然语法有些变化,但在v4中仍然需要在每次提交后开始事务。您会认为他们会以明显的方式在文档中包含这样一个重要细节。 - Aaron Bramson

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接