git s# Neo4j Transfer
A Python tool for efficiently transferring selected data from one Neo4j instance to another, with support for batch processing, progress tracking, and transfer metadata.
Features
- Selective Data Transfer: Transfer specific node labels and relationship types
- Batch Processing: Efficient large-scale transfers with configurable batch sizes
- Progress Tracking: Real-time progress updates during transfers
- Transfer Metadata: Optional augmentation with source element IDs and timestamps
- Undo Capability: Remove transferred data using the original transfer specification
- Database Reset: Option to clear target database before transfer
- Stoppable Transfers: Cancel long-running transfers gracefully
Documentation
Installation
From GitHub (Development)
pip install git+https://github.com/jalakoo/neo4j-transfer.git@main
From PyPI (When Available)
pip install neo4j-transfer
Quick Start
Basic Transfer
from neo4j_transfer import Neo4jCredentials, TransferSpec, transfer
# Define source and target database credentials
source_creds = Neo4jCredentials(
uri="bolt://localhost:7687",
username="neo4j",
password="source_password",
database="neo4j"
)
target_creds = Neo4jCredentials(
uri="bolt://localhost:7688",
username="neo4j",
password="target_password",
database="neo4j"
)
# Specify what to transfer
spec = TransferSpec(
node_labels=["Person", "Company"],
relationship_types=["WORKS_FOR", "OWNS"]
)
# Execute the transfer
result = transfer(source_creds, target_creds, spec)
print(f"Transfer completed: {result.nodes_created} nodes, {result.relationships_created} relationships")
Transfer with Progress Tracking
from neo4j_transfer import transfer_generator
# Use the generator for real-time progress updates
for update in transfer_generator(source_creds, target_creds, spec):
if hasattr(update, 'records_completed'):
progress = update.float_completed()
print(f"Progress: {progress:.1%}")
Transfer with Metadata Augmentation
spec = TransferSpec(
node_labels=["Person"],
relationship_types=["KNOWS"],
should_append_data=True, # Add transfer metadata
element_id_key="_source_element_id",
timestamp_key="_transfer_timestamp"
)
Undo a Transfer
from neo4j_transfer import undo
# Remove all data transferred with this spec
undo(target_creds, spec)
Advanced Usage
Database Reset Before Transfer
spec = TransferSpec(
node_labels=["Person"],
overwrite_target=True, # Clear target database first
batch_size=10000
)
Stoppable Transfer
gen = transfer_generator(source_creds, target_creds, spec)
controller = next(gen) # Get the controller
# In another thread or after some condition:
controller.request_stop()
# Continue consuming updates
for update in gen:
# Process updates until stop is requested
pass
API Reference
Neo4jCredentials
Credentials for accessing a Neo4j database instance.
uri(str): The URI address of the Neo4j databasepassword(str): The password for authenticationusername(str, optional): Username (default: "neo4j")database(str, optional): Database name (default: "neo4j")
TransferSpec
Configuration for data transfer between Neo4j instances.
node_labels(list[str]): Node labels to transferrelationship_types(list[str], optional): Relationship types to transfershould_append_data(bool): Add transfer metadata to copied data (default: True)element_id_key(str): Property key for source element ID (default: "_transfer_element_id")timestamp_key(str): Property key for transfer timestamp (default: "_transfer_timestamp")overwrite_target(bool): Clear target database before transfer (default: False)batch_size(int): Batch size for transfers (default: 10000)
UploadResult
Result object containing transfer statistics.
nodes_created(int): Number of nodes createdrelationships_created(int): Number of relationships createdrecords_total(int): Total records processedrecords_completed(int): Records completedwas_successful(bool): Whether transfer succeededseconds_to_complete(float): Transfer durationfloat_completed(): Returns completion percentage as float (0.0-1.0)
Requirements
- Python 3.11+
- Neo4j 4.0+
- Access to both source and target Neo4j instances
License
MIT License - see LICENSE.txt for details.
Metadata
Release files for neo4j-transfer 0.2.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 | Provenance | Actions |
|---|---|---|---|---|
| neo4j_transfer-0.2.0.tar.gz | 13.6 kB | Without provenance | Details for neo4j_transfer-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| neo4j_transfer-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for neo4j_transfer-0.2.0-py3-none-any.whl |
Total release size: 27.8 kB
Release files / neo4j_transfer-0.2.0.tar.gz
| Download URL | neo4j_transfer-0.2.0.tar.gz |
|---|---|
| Size | 13.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
47c152e0860224a9ca7c05573145598a79e7ada5db126a6890adc79e2c7cec33
|
|
BLAKE2b-256 checksum How to use checksums |
25eda395fd9e0fc5d83289808dc73ca1ed0fca27ccd0f59afb2362b9898792b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.12.0 Darwin/24.6.0
|
Release files / neo4j_transfer-0.2.0-py3-none-any.whl
| Download URL | neo4j_transfer-0.2.0-py3-none-any.whl |
|---|---|
| Size | 14.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
efb6ddf7368c172f97b4ef96ef8b4c531258553df93bee54c0acf8596075bad0
|
|
BLAKE2b-256 checksum How to use checksums |
d583d4cfe377f3803da12c90fcd2804da0ed410d2b557012b57570c0f765bdb3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.12.0 Darwin/24.6.0
|
Security for neo4j-transfer 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.