- Notifications
You must be signed in to change notification settings - Fork0
License
NotificationsYou must be signed in to change notification settings
jalakoo/neo4j-uploader
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
For uploading specially formatted dictionary data to a Neo4j database instance.
pip install neo4j-uploader
from neo4j_uploader import batch_uploadconfig = { "neo4j_uri": "<NEO4J_URI>", "neo4j_user": "<NEO4J_USER>", "neo4j_password": "<NEO4J_PASSWORD>", "overwrite": true}data = { "nodes": [ { "labels":["Person"], "key":"uid", "records":[ { "uid":"abc", "name": "John Wick" }, { "uid":"bcd", "name":"Cane" } ] }, { "labels":["Dog"], "key": "gid", "records":[ { "gid":"abc", "name": "Daisy" } ] } ], "relationships": [ { "type":"LOVES", "from_node": { "record_key":"_from_uid", "node_key":"uid", "node_label":"Person" }, "to_node": { "record_key":"_to_gid", "node_key":"gid", "node_label": "Dog" }, "exclude_keys":["_from_uid", "_to_gid"], "records":[ { "_from_uid":"abc", "_to_gid":"abc" } ] } ]}result = batch_upload(config, data)
The originalupload
function using the simpler schema also still works:
from neo4j_uploader import uploadcredentials = ("database_uri", "user", "password")data = { "nodes": { "Person": [ {"name": "Bob", "age": 30}, {"name": "Jane", "age": 25} ] }, "relationships": { "KNOWS": [ {"_from_name": "Bob", "_to_name": "Jane", "since": 2015} ] }}upload(credentials, data, node_key="name)
Thebatch_upload_generator
function can be used as a generator. Example usage:
for result in batch_upload(config, data): print(f"Upload progress: {result.nodes_created} nodes created")
Documentation for the current version.
About
No description, website, or topics provided.
Resources
License
Stars
Watchers
Forks
Packages0
No packages published