简体   繁体   English

py2neo引发完成(自我)错误

[英]py2neo raised finished(self) error

Working with py2neo and I'm getting the error below when trying to append a transaction: 使用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)

The traceback is: 追溯是:

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

any ideas? 有任何想法吗?

You will get this error if you call tx.commit() twice without a tx = graph.cypher.begin() in between. 如果您在两次之间调用tx.commit()而没有tx = graph.cypher.begin(),则会出现此错误。 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()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM