Yann
Yann

Reputation: 1019

Batch execute CREATE statements in Cypher / Neo4j

In Neo4j / Cypher: I have a file that contains about 80,000 statements like this one:

create (n:contract {numctr:"35129",CDETYPCTR:"GENERAL",DATDBTCTR:"455407200000",DATTFINCTR:"455407200000"});

I want to import them in my local neo4j server; when I drag the file to the "Drop a file to import Cypher or Grass" area in the neo4j admin, I get a silent failure (nothing is imported, I can't find an error message).

Is there a better way to execute all the statements in my file, like one would do in mysql:

mysql -u username -p database_name < file-to-import.sql

Thanks

Yann

Upvotes: 0

Views: 1055

Answers (1)

Michael Hunger
Michael Hunger

Reputation: 41706

It's almost the same in Neo4j, if you have semicolon separated statements.

It also helps if you put a BEGIN at the beginning and a COMMIT at the end of your 80k statements so that they are all executed in one transaction.

bin/neo4j-shell -file file-to-import.cql

The shell connects to a running server, if you want to create a new datastore you can provide -path path/to/graph.db

Upvotes: 3

Related Questions