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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: neomate-0.1.0.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.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 53763a871766a774fa2ca725ec654afaaea2f2c312559250cca0a7321a4e81bb
MD5 1a135d38b938630e56812480e3b8ed7d
BLAKE2b-256 b4477c4ca21d1ae5df863114b87fcad88eaf9074df021b917ec6cb516f5e082f

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