How to execute Cypher in a file?

前端 未结 6 1159
情深已故
情深已故 2021-01-04 01:39

I am working on windows. I have created a text file of Cypher query using notepad. How can I run the query in the file using Neo4jShell or Neo4j web interface console.

6条回答
  •  醉梦人生
    2021-01-04 01:53

    With Neo4j web interface I just do copy&paste.

    On the console I sometimes use curl to talk to Neo4j's REST interface. That allows me to use the same queries (with references to separate parameters) that I have in my application. You have to wrap the query in your file into a json object for that.

    data.json:

    {
      "query":"match (u:User) where u.username={username} return u",
      "params":{"username":"trenkerbe"}
    }
    

    command:

    curl -i -X POST -H "Content-Type: application/json" -d @data.json http://localhost:7474/db/data/cypher
    

提交回复
热议问题