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.0.tar.gz (9.3 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.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: neomate-0.1.0.tar.gz
  • Upload date:
  • Size: 9.3 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.0.tar.gz
Algorithm Hash digest
SHA256 4630b90b1a67df57d135a7ad4a31f53757803b2a0570b197096e684bd2eb3209
MD5 fbfba254b76613ef327483b1c93f3943
BLAKE2b-256 14c7d9cd2905fc1c7b04e7f0b4acdd678103be340af04a995214d271f987a128

See more details on using hashes here.

File details

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

File metadata

  • Download URL: neomate-0.1.0-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-py3-none-any.whl
Algorithm Hash digest
SHA256 a621a357ee989c5d88cbbb395c078b87be056fd5e8a57474f7ea2d34b5486223
MD5 6233bceb1d277ede60e6fbc0ed22c2af
BLAKE2b-256 72dde5e572dc0af7e805fa2dc5a3b69d7ecca448fbad34fac14e0f97c86e75fd

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