Ability to execute "batch queries" via a .cql or .cypher file from embedded java

cypher

(Sporkisfaster) #1

Does anyone know if its possible to execute .cql or .cypher files programmatically in embedded java mode as sort of a "batch" operation? I have numerous queries in a .cql file that I'd like to use whenever I spin up a new database using something like transactions in java: https://neo4j.com/docs/java-reference/current/tutorials-java-embedded/#tutorials-cypher-java . All I see is you can manually type out the query as a parameter but I was hoping there was functionality to pass an entire file.


(Michael Hunger) #2

You can split the file by a Semicolon at the end of the line.
And then execute each of those parts with db.execute(statement)

java.util.Scanner works well for that, that's what I use in APOC's apoc.cypher.runFile too.