The easiest ways to get data into Neo4j Aura are either by uploading a CSV file to a web server and using the Neo4j Browser to LOAD CSV from that file. Additionally, local instances of Neo4j provide more flexible data loading options. You may wish install Neo4j Desktop or Enterprise into your local instance, then use one of the available tools to upload the database into Neo4j Aura.
This KB article will review several methods of loading data:
Method | Pros | Cons |
Use the LOAD CSV command to load data from a file hosted on a web server | Easy | Requires data be accessible over the open web |
Drag and drop a dump file created from a local database | Load step is drag-and-drop |
Requires local install of Neo4j Limited to 4GB |
Using the `neo4j-admin push-to-cloud` and `neo4j-admin database upload` commands |
Unlimited load size | Requires local install of Neo4j |
Use a programmatic connection to load or create data. | Most flexible | Most complex |
Method 1: Use the LOAD CSV command to load data from a file hosted on a web server
1. Upload your CSV file to a web server where it is available by http, https, ftp, etc. For the purposes of this example, we'll use the Github-hosted file at "https://raw.githubusercontent.com/amaboura/panama-papers-dataset-2016/master/de.csv"
2. In the Neo4j Browser, use the LOAD CSV command to load the file directly into your Aura instance
LOAD CSV WITH HEADERS FROM
"https://raw.githubusercontent.com/amaboura/panama-papers-dataset-2016/master/de.csv" AS row
MERGE (n:Node {node_id:row.id}) ON CREATE SET n = row, n:de_node;
The following resources contain additional relevant information:
Note: As an alternative to exposing your CSV file on the Internet, it’s possible to use a signed URL, which is a time-limited and secure link to access your file. This functionality is supported by most of the public cloud service providers.
Method 2: Drag and Drop a dump file created from a local database.
The easiest way to bulk-load non-CSV data, or even CSV data that you do not with to upload to another service, is to import it into a local Neo4j instance and create a dump of that instance. You can then use that dump file to populate your Neo4j Aura instance.
This method requires that you have a local Neo4j Desktop or Neo4j Enterprise instance running.
1. Stop the Database with the following command in the browser:
stop database neo4j;
2. Create the dump.
The process for creating a dump file via Neo4j Desktop is different from the process on Neo4j Enterprise.
From Neo4j Desktop:
a) click on the three dots of the database tile and select the Dump option.
The dump will appear under the Files section in the Neo4j Desktop interface.
b) Use the Reveal in Files option to open the directory containing the dump files
From Neo4j Enterprise:
a) Use the neo4j-admin command to create the dump
neo4j-admin dump --database=<database> --to=/path/to/dump
b) Find the dump file in your file manager at the path you specified in the neo4j-admin command
3. Open the Neo4j Aura console and select your AuraDB Instance.
4. Drag and drop the dump file into the 'Import Database' tab.
The following resources contain additional relevant information:
Method 3: Using the `neo4j-admin push-to-cloud` and `neo4j-admin database upload` commands
Note this method requires a local installation of Neo4j Enterprise Edition
From your operating systems command line, issue the commands
$neo4j-home> bin/neo4j stop
$neo4j-home> bin/neo4j-admin push-to-cloud \
--bolt-uri=neo4j://mydatabaseid.databases.neo4j.io
\
--dump-to=/local/dump/path \
--username=neo4j \
--password=<your password (optional, see notes)
For Neo4j 5.x and later, please review the below code as the command has changed to the Database Upload command:
bin/neo4j-admin database upload \
--verbose
--overwrite-destination=true \
--from-path=import \
--to-uri=neo4j+s://123456.databases.neo4j.io\
--to-user=neo4j \
--to-password=<myTopSecret> \
neo4jv5
For more information on this command please review the following KBA: https://aura.support.neo4j.com/hc/en-us/articles/10932963739539-Using-neo4j-admin-database-upload-in-Neo4j-5-x-to-load-a-database-dump-to-Neo4j-Aura
Note: If you do not provide a password, you will be prompted for one
The following resources contain additional relevant information:
Method 4: Use a programmatic connection to load data.
The "Connect" Tab on the left side of the Neo4j Aura console offers examples in several languages for connecting to your AuraDB Instance programmatically.
1. Log in to Neo4j Aura console and click 'Connect'.
2. Choose your language and copy the example to your favourite editor
Use the "Copy to Clipboard" icon to copy the example and start editing. The panel on the right of the screen includes important information like pre-requisites and other caveats, so be sure to review it!
Going beyond the example
The examples contain individual CREATE statements which create entries one node at a time. If you have bulk data (ie JSON or CSV files that you do not wish to load via one of the above methods), you will likely want to explore Cypher's UNWIND statement
The following resources contain additional relevant information:
- Neo4j Sessions and Transactions (NOTE: Neo4j Aura requires the use of transaction functions)
- UNWIND
- Using unwind and Python dict to populate AuraDB Instance
Comments
0 comments
Please sign in to leave a comment.