问题描述
我正在使用 neo4j-java-driver(bolt 端口)将我的 java 应用程序与 neo4j DB 连接起来。我想运行一个加载 CSV 查询,该查询应该以 500 个为一组运行,所以我想使用定期提交。所以首先,我使用了:
USING PERIODIC COMMIT 500 ...
Caused by: org.neo4j.driver.exceptions.ClientException: Executing queries that use periodic commit in an open transaction is not possible.
我在这里找到了一些关于它的答案,说我应该在查询前添加 :auto
,所以我这样做并得到了这个错误:
Caused by: org.neo4j.driver.exceptions.ClientException: Invalid input ':': expected <init> (line 1,column 1 (offset: 0))
:auto USING PERIODIC COMMIT 500
^
解决方法
https://neo4j.com/docs/driver-manual/1.7/sessions-transactions/
在这种情况下,我们需要使用自动提交事务。正如文件所说:
自动提交事务是执行 USING PERIODIC COMMIT Cypher 语句的唯一方法。
示例:
...this.state
,
在 python 中工作时面临同样的问题。您可以根据需要使用apoc
apoc.periodic.iterate('statement returning items','statement per item',{batchSize:1000,iterateList:true,parallel:false,params:{},concurrency:50,retries:0})
或
apoc.periodic.commit(statement,params)