Skip to main content

Lightweight Neo4j ORM with type validation and relationship management

Project description

NeoMate

A lightweight and intuitive ORM for Neo4j in Python, providing type validation, relationship management, and elegant query building.

Features

  • Type validation system using dataclasses
  • Transaction management with automatic rollback on errors
  • Relationship creation and management
  • Flexible node querying with AND/OR conditions
  • Colored logging for better debugging
  • Bulk node creation support
  • Bidirectional relationship support
  • Custom type validation

Installation

pip install neomate

Quick Start

from neomate import NeoMate, Types
from neo4j import GraphDatabase

# Define your model
class Person:
    __nodename__ = "Person"  # Optional: customize node type name
    
    name = Types(str, is_must_have=True)
    age = Types(int, default=0)
    hobbies = Types(list, is_must_have=False)

# Connect to Neo4j
uri = "neo4j://localhost:7687"
driver = GraphDatabase.driver(uri, auth=("neo4j", "password"))
session = driver.session()

# Initialize NeoMate
neo = NeoMate(session)

# Create a person
person = Person()
person.name = "Alex"
person.hobbies = ["programming", "music"]

# Save to database
neo.create_node(person)

# Query nodes
results = neo.get_node("Person", name="Alex")

Type Validation

The Types class supports:

  • Basic Python types (str, int, list, etc.)
  • Custom classes
  • Optional fields with is_must_have=False
  • Default values
  • Bidirectional relationships
class User:
    name = Types(str, is_must_have=True)
    friend = Types("User", relate_name="FRIEND", bidiractional=True)

Transaction Management

All database operations are automatically wrapped in transactions:

# Automatic transaction management
neo.add_node("Person", name="John")

# Multiple nodes in single transaction
nodes = [
    {"name": "Alice", "age": 25},
    {"name": "Bob", "age": 30}
]
neo.add_nodes("Person", nodes)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Credits

Created by Alex

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

neomate-0.1.1.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

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

neomate-0.1.1-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file neomate-0.1.1.tar.gz.

File metadata

  • Download URL: neomate-0.1.1.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for neomate-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6f8cb43dcecc40d45daaaca5aed1e619a0ed3007f626bba43b89e64c1cd9664f
MD5 4ade4ffdf31f0253557e53f2d28d7e0e
BLAKE2b-256 9740d2b36cc286c91ce4bd9b77c63d33db803e3fc862b6b65b2dd58dda85a4cc

See more details on using hashes here.

File details

Details for the file neomate-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: neomate-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for neomate-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 37f948f7c29c97c114d8d2827642a06b5af777e3e4edad951166ecbef8c197ca
MD5 dd2c1e037b0783800bf341f5a0e113c0
BLAKE2b-256 861e1269e12327159fc3ffc1e2837e60343ac7b3f5986fddadd91a995885caa6

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