Reputation: 349
I am trying to load the node from csv in Neo4j, however, every time I try to do this I get such an error:
Neo.ClientError.Statement.ExternalResourceFailed: Couldn't load the external resource at: file:/var/lib/neo4j/import/events.csv
My event.csv file is in /var/lib/neo4j/import
directory with 777 permissions. The query I try to run looks like this:
USING PERIODIC COMMIT 500 LOAD CSV WITH HEADERS FROM "file:///events.csv" AS line
CREATE (e:Event { event_id: toInteger(line.event_id),
created: line.created,
description: line.description })
I set up Neo4j using the latest version of docker image. What might be wrong with file permissions or file location?
Upvotes: 0
Views: 902
Reputation: 154
In addition to mounting the "dataimport" volume when running the container, make sure you have the following configuration in the neo4j.conf file in conf dir:
server.directories.import=/var/lib/neo4j/import
dbms.security.allow_csv_import_from_file_urls=true
This is my docker run command:
docker run \
--restart always \
--detach \
--publish=7474:7474 --publish=7687:7687 \
--env NEO4J_PLUGINS='["apoc", "graph-data-science", "bloom"]' \
--volume=/opt/neo4j/data:/data \
--volume=/opt/neo4j/logs:/logs \
--volume=/opt/neo4j/conf:/conf \
--volume=/opt/neo4j/import:/var/lib/neo4j/import \
--env NEO4J_AUTH=neo4j/my_password\
neo4j:5.9.0
Upvotes: 0
Reputation: 7803
Docker container cannot get access to files outside on the host machine, unless you mount those files to the container.
Solution is to bind-mount the directory to your container when calling the docker run
command:
docker run -v /var/lib/neo4j/import:/var/lib/neo4j/import ... <IMAGE> <CMD>
Upvotes: 2