I am trying to create a graph by loading a CSV file to neo4j from scala code.
I'm using a periodic commit which is resulting in the following error:
Exception in thread "main" org.neo4j.driver.v1.exceptions.ClientException:
Executing queries that use periodic commit in an open transaction is not possible.
Any help on why I get this error and how to avoid it? I am using periodic commit as I would be loading over 100k nodes. Is there any alternative to periodic commit?
Code:
def createGraph(createStmt: ArrayBuffer[String]): Unit = {
val session = driver.session()
val greeting: String = session.writeTransaction(new TransactionWork[String]() {
override def execute(transaction: Transaction): String = {
var result1: StatementResult = transaction.run("USING PERIODIC COMMIT\n"+
"LOAD CSV WITH HEADERS FROM \"file:///path/to/file.csv\" AS csvLine\n"+
"CREATE (p:Person {id: toInt(csvLine.id), name: csvLine.name})")
"Graph Created"
}
})
}
session.run(...)
, without starting a new transaction. – Gabor Szarnyas