我想通过在neo4j的shell或power控制台中使用命令来运行脚本文件。 有办法吗?
澄清:实际上是从shell中运行脚本的目标。
用于运行groovy脚本的 gsh 命令。
答案 0 :(得分:0)
看看Mark Needham的世界杯数据集GitHub示例,他使用Neo4j shell运行一系列Cypher脚本进行数据导入。
https://github.com/mneedham/neo4j-worldcup/blob/master/doit.sh
#! /bin/bash
set -e
if [[ -z "$WC_DB" ]]; then
echo "Make sure you set \$WC_DB before running this script"
echo "e.g. export WC_DB=\"/path/to/neo4j-community-2.1.4\""
exit 1
fi
echo "starting up Neo4j instance at ${WC_DB}"
${WC_DB}/bin/neo4j status
if [ $? -ne 0 ]; then
echo "Neo4j not started. Run ${WC_DB}/bin/neo4j start before running this script"
fi
${WC_DB}/bin/neo4j-shell --file data/import/clear.cyp
${WC_DB}/bin/neo4j-shell --file data/import/indexes.cyp
${WC_DB}/bin/neo4j-shell --file data/import/loadMatches.cyp
${WC_DB}/bin/neo4j-shell --file data/import/loadSquads.cyp
${WC_DB}/bin/neo4j-shell --file data/import/loadLineUps.cyp
${WC_DB}/bin/neo4j-shell --file data/import/loadEvents.cyp
${WC_DB}/bin/neo4j-shell --file data/import/connectAdjacentWorldCups.cyp
${WC_DB}/bin/neo4j-shell --file data/import/addGeoLocations.cyp
${WC_DB}/bin/neo4j-shell --file data/import/loadCountryInformation.cyp
${WC_DB}/bin/neo4j-shell --file data/import/addContinents.cyp
确保已导出系统变量$WC_DB
以包含正在运行的Neo4j实例的路径。您可以看到标志--file
允许您将Cypher脚本作为文件传递给neo4j-shell
作为参数。