Neo4j-uploader
For uploading specially formatted dictionary data to a Neo4j database instance.
Installation
pip install neo4j-uploader
Usage
from neo4j_uploader import batch_upload
config = {
"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 original upload function using the simpler schema also still works:
from neo4j_uploader import upload
credentials = ("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)
Progress Tracking
The batch_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
Documentation for the current version.
Release files for neo4j-uploader 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| neo4j_uploader-0.6.0.tar.gz | 16.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| neo4j_uploader-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.9 kB
Release files / neo4j_uploader-0.6.0.tar.gz
| Download URL | neo4j_uploader-0.6.0.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d0c7228add6f943a3aff98a2d1925cc29d354d4f3bfbe9a9fce5ecea33db3a3e
|
|
BLAKE2b-256 checksum How to use checksums |
dcfc12452f9020701835110193564f8fdf4ee913a4ac1171c12e680dc0ad9486
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.12.2 Darwin/23.4.0
|
Release files / neo4j_uploader-0.6.0-py3-none-any.whl
| Download URL | neo4j_uploader-0.6.0-py3-none-any.whl |
|---|---|
| Size | 18.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
239dfd7afd0bfd96778d6a96d9b900669febb99699c46802056cdb6b6df6a80b
|
|
BLAKE2b-256 checksum How to use checksums |
6778a53eb1cb0d827dd9c07f31cdbfc1b0d3d1a322749d89c40e9fb20bee838f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.12.2 Darwin/23.4.0
|