Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-05-2020 12:02 PM
Hello friends!
I would like some tips about an ETL process that I'm working for. I have create a Cypher statment using APOC to read data from SQL SERVER and write it in Neo4j. The statment is working fine, but I have to run it manually every time that I need to update the Neo4j database.
I would like to create a JOB that every day at 10:00 PM executes a Cypher statment that update the Neo4j database automaticaly. Is there some way to create a batch file that I can run a Cypher statment via comand line?
Solved! Go to Solution.
03-10-2020 11:08 PM
Hi eulervicente,
I ran slow Windows 10 on my Mac with Parallels.
And I created create_node.txt like this.
CREATE (:Person)
And I wrote this simple code.
type .\import\create_node.txt | .\bin\cypher-shell.bat -a bolt://localhost:7687 -u neo4j -p abcde
There were no errors, but no nodes were created.
So I added a semicolon to create_node.txt.
CREATE (:Person);
Maybe I think your error is the same cause.
You should be able to add a semicolon to the end of the last line and it will work.
03-05-2020 03:40 PM
Hi eulervicente,
This is a sample if you can write bash.
#!/bin/bash
readonly MYCYPHER="/dir/to/yourcypher.txt"
readonly NEO4J_HOME="/dir/to/neo4jhome"
readonly BOLT_ADDRESS="bolt://localhost:"
readonly BOLT_PORT="7687"
readonly NEO4J_USER="neo4j"
readonly NEO4J_PW="yourpassword"
cat ${MYCYPHER} | ${NEO4J_HOME}/bin/cypher-shell -a ${BOLT_ADDRESS}${BOLT_PORT} -u ${NEO4J_USER} -p ${NEO4J_PW}
exit 0
03-10-2020 05:51 AM
Hi Koji! Thank you very much!
Could you help me to do a version for Windows ? I am trying to do it but without success. I run the batch file but nothing happens. I have tested the Cypher statment in the Neo4j web browser and it is working correctly.
Check it out my batch file code:
set MYCYPHER="mycypher.txt"
set NEO4J_HOME="D:\NEO4J\neo4j-community-3.5.11-windows"
set BOLT_ADDRESS="bolt://localhost:7687"
set NEO4J_USER="neo4j"
set NEO4J_PW="mypassword"
D:
cd D:\NEO4J
type %MYCYPHER% | %NEO4J_HOME%\bin\cypher-shell -a %BOLT_ADDRESS% -u %NEO4J_USER% -p %NEO4J_PW%
03-10-2020 11:08 PM
Hi eulervicente,
I ran slow Windows 10 on my Mac with Parallels.
And I created create_node.txt like this.
CREATE (:Person)
And I wrote this simple code.
type .\import\create_node.txt | .\bin\cypher-shell.bat -a bolt://localhost:7687 -u neo4j -p abcde
There were no errors, but no nodes were created.
So I added a semicolon to create_node.txt.
CREATE (:Person);
Maybe I think your error is the same cause.
You should be able to add a semicolon to the end of the last line and it will work.
03-11-2020 06:08 AM
Hello Koji!
Thanks! It's working now.
I found out an alternative way to do this same task using an APOC procedure: apoc.cypher.runFiles.
call apoc.cypher.runFiles(["ETL_NodeLicitacao.txt","ETL_RelacaoLicitou.txt","ETL_RelacaoCotou.txt"],{}) yield row, result;
03-05-2020 04:30 PM
All the sessions of the conference are now available online