I would like to predefine some graph data for neo4j and be able to load it, maybe via a console tool. I'd like it to be precisely the same as MySQL CLI and .sql
files. Does anyone know if there exists a file format like .neo
or .neo4j
? I couldn't find such thing in the docs...

- 25,621
- 41
- 157
- 256
-
What language would this script be written in? Cypher? – ean5533 Mar 01 '13 at 16:03
-
yep - exactly. Just to write queries. – ducin Mar 02 '13 at 09:59
3 Answers
We usually do .cql or .cypher for script files. You can pipe it to the shell to run it, like so:
./neo4j-shell -c < MY_FILE.cypher
Michael Hunger was doing some great work on this feature, also, just recently. He got performance up and noise down from the console. I hope it gets into 1.9 release.

- 6,300
- 3
- 46
- 67

- 32,467
- 4
- 86
- 101
-
Is there any way to run this from within neo4j-sh? e.g. @myScript.cql ? – Sridhar Sarnobat Mar 25 '13 at 05:45
-
-
Okay, thanks Wes. You've saved me time that I'd have wasted stubbornly believing there is a way to do it. Hopefully someone will add a feature request :) – Sridhar Sarnobat Mar 25 '13 at 15:48
-
@EveFreeman / @Sridhar-Samobat I've added such a way to neo4j-client, using the `:source` client command (see the alternative answer). – Chris Leishman Aug 21 '16 at 22:31
From https://groups.google.com/forum/#!topic/opencypher/PO5EnspBLs0
1:
"Sorry for the late reply, but we just wanted to inform you that the official recommendation is to use
.cypher
. We'll be formalising this in the style guide soon."
2:
"In training run by Neo4j, we've historically used .cyp. I believe the preference is to use .cypher, and .cyp when an extension of 3 chars is required."
3:
"Note: '.cql' is already used for Cassandra - https://cassandra.apache.org/doc/cql/CQL.html"
From the above extracts:
1st preference is .cypher
2nd preference is .cyp
(1st 3 characters of cypher)
Don't use .cql
More:
If you need a color coding in notepad++, download the xml given at https://gist.github.com/nicolewhite/b0344ea475852c8c9571 , import it via menu Language > User Defined Language > Import > Restart the Notepad++, open a file with .cypher that has some cyper query language)
Sample cypher is below:
MATCH (:Person {name: "Ann"}) -[:FB_FRIENDS]-> Create (:Person {name: "Dan"})
Hope that helps someone.

- 25,399
- 9
- 157
- 140
Using neo4j-client as the CLI for Neo4j allows for easy evaluation of scripts. There are several ways to work with a script containing multiple cypher commands:
You can pipe the script in via standard input, e.g.:
neo4j-client -u neo4j -P localhost < my_script.cyp
You can use the command line option
--source
or-i
, e.g.:neo4j-client -u neo4j -P -i my_script.cyp localhost
You can start an interactive shell, and then source the script:
$ neo4j-client localhost Username: neo4j Password: ***** neo4j-client 1.2.1. Enter `:help` for usage hints. Connected to 'neo4j://neo4j@localhost:7687' neo4j> neo4j> :source my_script.cyp
The extension .cyp
is most commonly used for scripts.

- 1,777
- 13
- 19