Skip to main content

Neo4j persistence adapter for Pydantic Graph

Project description

Pydantic Graph - Neo4j Persistence

PyPI Version Build Status License

Overview

pydantic_graph_neo4j_persistence is a persistence adapter for Neo4j that seamlessly integrates with Pydantic models. It enables saving node snapshots directly into a Neo4j database, facilitating efficient graph data management within Python applications.

Features

  • Seamless Integration: Effortlessly combine Pydantic's data validation with Neo4j's graph database capabilities.
  • Automatic Snapshotting: Automatically persist node states to Neo4j, ensuring data consistency.
  • Flexible Configuration: Tailor the persistence layer to fit various application architectures.

Installation

To install pydantic_graph_neo4j_persistence, use pip:

pip install pydantic_graph_neo4j_persistence

Quick Start

Here is a basic example demonstrating how to use pydantic_graph.neo4j_persistence:

from pydantic_graph_neo4j_persistence import Neo4jStatePersistence

async def run_as_cli(answer: str | None):
    persistence = Neo4jStatePersistence(
        uri="your_uri",
        username="your_username",
        password="your_password",
        execution_id="execution_id",
        verbose=False
    )

    persistence.set_graph_types(my_pydantic_graph)

    ...
    


if __name__ == '__main__':
    import asyncio
    import sys
    
    a = sys.argv[2] if len(sys.argv) > 2 else None
    asyncio.run(run_as_cli(a))

You can see a full example on the oficial pydantic documentation. From there just change the persistence variable to use the Neo4jStatePersistence

Nodes and Relationships

The Neo4jStatePersistence uses and require the following Nodes:

  • NodeSnapshot
  • EndSnapshot
  • Execution

And the following relationship:

  • HAS_SNAPSHOT

(e:Execution) ->[:HAS_SNAPSHOT]->(n:NodeSnapshot) (e:Execution) ->[:HAS_SNAPSHOT]->(n:EndSnapshot)

Contributing

We welcome contributions to enhance the functionality and usability of pydantic_graph.neo4j_persistence. To contribute:

Fork the repository.

Create a new branch for your feature or bug fix.

Ensure existing tests pass and add new tests for your changes.

Submit a pull request detailing your changes and the problem they address.

License

pydantic_graph.neo4j_persistence is licensed under the MIT License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_graph_neo4j_persistence-0.1.4.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file pydantic_graph_neo4j_persistence-0.1.4.tar.gz.

File metadata

File hashes

Hashes for pydantic_graph_neo4j_persistence-0.1.4.tar.gz
Algorithm Hash digest
SHA256 d6a4792e90fc82ce4b10d0225253a6635e162deed703aaa1997a77865138adb3
MD5 b9bb14d98559107e1df5f63885f1a4c9
BLAKE2b-256 39f6aa80bee6795244718e84b028f6b6691a9fef82153986ba1e4f56882e7c07

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_graph_neo4j_persistence-0.1.4.tar.gz:

Publisher: python-publish.yml on Goduu/pydantic_graph.neo4j_persistence

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydantic_graph_neo4j_persistence-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for pydantic_graph_neo4j_persistence-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3c1a74847c8d37d45e7f02c5267be270ab8749f4b746a7eda4f4b138c9e7b555
MD5 604fc4d0867000d2a42727133a9986e2
BLAKE2b-256 3d584b0318ec404c6531c36bbd63ed170acf23aa3cb3c53076350a6c7e08bf56

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydantic_graph_neo4j_persistence-0.1.4-py3-none-any.whl:

Publisher: python-publish.yml on Goduu/pydantic_graph.neo4j_persistence

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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