Skip to main content

OGM and data loader for Neo4j.

Project description

GraphIO

Tests PyPI License Neo4j Python Downloads

OGM and data loader for Neo4j with two main approaches:

  • OGM (Object Graph Mapper): Pydantic-based models with Neo4j integration for complex data models and applications
  • Datasets (NodeSet/RelationshipSet): Bulk data containers optimized for fast data loading and testing
  • Multi-Database Support: Full support for Neo4j Enterprise Edition multi-database feature

Documentation

Docs available at: https://graphio.readthedocs.io

Quick Start

Installation

Install graphio from PyPI:

pip install graphio

Install the latest version from GitHub:

pip install git+https://github.com/kaiserpreusse/graphio.git

Example

from graphio import NodeModel, Base
from neo4j import GraphDatabase

# Set up connection
driver = GraphDatabase.driver('neo4j://localhost:7687', auth=('neo4j', 'password'))
Base.set_driver(driver)
# Optional: Set target database (Enterprise Edition)
# Base.set_database('production')

# Define OGM model for structure and validation
class Person(NodeModel):
    _labels = ['Person']
    _merge_keys = ['email']
    name: str
    email: str

# Get bulk container directly from OGM model
people = Person.dataset()  # Automatically uses Person's labels and merge_keys

for person_data in large_dataset:
    # Create validated OGM instance and add directly
    person = Person(**person_data)  # Pydantic validation happens here
    people.add(person)  # Add validated instance to bulk dataset

people.create(driver)  # Bulk create with validation benefits

# Use OGM for application logic
alice = Person.match(Person.email == 'alice@example.com').first()

Development

Prerequisites

  • Python 3.10+
  • uv (recommended) or pip
  • Docker for running test databases

Setup

# Clone the repository
git clone https://github.com/kaiserpreusse/graphio.git
cd graphio

# Install dependencies
uv sync --extra dev

# Start Neo4j test databases
make localdb

Common Commands

# Run tests
make test

# Check code style  
make lint

# Format code
make format

# Fix linting issues and format
make fix

# Run all checks (lint + test)
make check

# Serve documentation locally
make docs

# See all available commands
make help

Testing

The test suite requires Docker containers running Neo4j. Start them with:

make localdb

Then run tests with:

make test
# or directly:
uv run pytest

All tests using the graph fixture will run against both Neo4j Community and Enterprise editions.

Feedback

Please provide feedback, ideas and bug reports through GitHub issues.

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

graphio-0.20.tar.gz (79.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

graphio-0.20-py3-none-any.whl (24.3 kB view details)

Uploaded Python 3

File details

Details for the file graphio-0.20.tar.gz.

File metadata

  • Download URL: graphio-0.20.tar.gz
  • Upload date:
  • Size: 79.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for graphio-0.20.tar.gz
Algorithm Hash digest
SHA256 26822386b46ba22b879b83e000cbbcfbfcb8182f6832e179df96084e5a65accd
MD5 ad2ff7fa6e2a0b439f98e591dab581d2
BLAKE2b-256 baca757b3cd4e6b67a3b0405568e3c9248c87eb2946c40c5ba2075b75a1637b3

See more details on using hashes here.

File details

Details for the file graphio-0.20-py3-none-any.whl.

File metadata

  • Download URL: graphio-0.20-py3-none-any.whl
  • Upload date:
  • Size: 24.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for graphio-0.20-py3-none-any.whl
Algorithm Hash digest
SHA256 5c56403a9e158b2499da8f2c366c8d5b80fc9cf0ab864990d32d58019454c269
MD5 b317fad098c9edc4333eb7ca6a3845ed
BLAKE2b-256 b98254db83dd764fac0e5c95273acdd5442c54ef6f19686414af1b3135d08bef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page