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.1.tar.gz
.
File metadata
- Download URL: neo4j_uploader-0.4.1.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.3 Darwin/23.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38bcf69bdce4b8f0aeffdb2d71c6f66d98facb59a0c85720bcf77e94f33ed3c6 |
|
MD5 | ef7e71eab78a644a6d763381fadb7960 |
|
BLAKE2b-256 | 0858fccd4f09c6661e66fe25e9e4dd3300abf6cd99de1429be06d63fc5bdfe4f |
File details
Details for the file neo4j_uploader-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: neo4j_uploader-0.4.1-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.11.3 Darwin/23.1.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 884f634e959d6dd704f8b515caffb5994d0b2a6e5801e52456cf29cc8696dad7 |
|
MD5 | 7b4ee3225b777099a9297a1968c948cb |
|
BLAKE2b-256 | fe52d322907d7d3dfe04cb614792aba259bc42e4c63abf17c89a5cc1f7c9f904 |