No project description provided
Project description
Neo4j-uploader
For uploading specially formatted dictionary data to a Neo4j database instance.
Installation
pip install neo4j-uploader
Usage
In your application
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)
Arguments
credentials
- A tuple of (database_uri, user, password)data
- A dictionary of nodes and relationships to upload. See the Data Argument Format section for more details.node_key
- The name of the key in the nodes dictionary that contains the node name. Defaults to "name"dedupe_nodes
- If True, will not upload duplicate Nodes. Only updates existing with specified properties. Defaults to Truededupe_relationships
- If True, will not created duplicate Relationships. Only updates existing with specified properties. Defaults to Trueshould_overwrite
- If True, will clear existing constraints, and will overwrite any existing Nodes and Relationships. Defaults to False.
Data Argument Format
Either a .json string or dictionary can be passed as an arg into the upload() function.
This dictionary must have a key named nodes
and optionally one named relationships
The value for the nodes
key must be a dictionary, where each key is the primary node label for the node records to upload. The value of each is a list of dictionaries that represent node properties to upload.
The value for the relationships
key must be a dictionary, where each key is relationship type. The value of each is a list of dictionaries that are the relationship properties to upload.
Every node record dictionary must have a unique key specified in the node_key
argument. The default is _uid
if none is provided. Relationships must have both _from_<node_key>
and _to_<node_key>
key-values to determine which Nodes a Relationship should connect. By default these would need to be _from__uid
and _to__uid
if a node_key is not provided to the upload()
function.
Example .json using a custom node_key:
{
"node_key": "nid",
"nodes": {
"Person": [
{
"first_name": "Jaclyn",
"last_name": "Stacey",
"nid": "b267e10d-998b-4804-b5a5-fe84b9ee982a"
},
{
"first_name": "Ryan",
"last_name": "Adam",
"nid": "0053fd25-71e4-40c1-80ff-f6b7e4211c77"
}
]
},
"relationships": {
"LIVES_WITH": [
{
"_from_nid": "b267e10d-998b-4804-b5a5-fe84b9ee982a",
"_to_nid": "0053fd25-71e4-40c1-80ff-f6b7e4211c77",
"since" : "2018-02-01"
}
]
}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file neo4j_uploader-0.4.0.tar.gz
.
File metadata
- Download URL: neo4j_uploader-0.4.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.3 Darwin/22.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba16904b9882885c90ac44ddb5d2cd0e93b410a781094c3fed570d1ff0bc3c42 |
|
MD5 | 46c58a017289f6f5d661d064dbd03318 |
|
BLAKE2b-256 | 13a59678871273b094ad6c965f63fdc439cac26d97d6dba4d7381184c0ff63ac |
File details
Details for the file neo4j_uploader-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: neo4j_uploader-0.4.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.3 Darwin/22.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 027281b496b66919dc4688df160248dc72d2cfce8af9b2301433ae2e7b1794cd |
|
MD5 | 85b177f661c08ac914f6cd37291394fc |
|
BLAKE2b-256 | dd98f814de9dab038f8dd17f5eb7d1c295b2badf2992a85c949838afc9b9002e |