Skip to main content

loomi

CI Python Version License: MIT

A minimalistic Python Object-Graph Mapper designed to handle the most common tasks when working with Neo4j or Memgraph.

Features

  • Hybrid Sync/Async Architecture: Built around the driver provided by the neo4j, loomi supports both sync and async clients.
  • Dual-Database Support: Compatibility with both Neo4j and Memgraph out of the box.
  • Type Safety: Fully typed models and queries thanks to pydantic.
  • Compatibility out of the box: Drop-in replacement when you already use the driver provided by the neo4j package. Enable additional features as required.

Installation

Install via pip or your favorite package manager:

pip install loomi

Or with poetry:

poetry add loomi

Quick start

1. Define your schema

from loomi import Node, Relationship
from pydantic import Field

class Child(Node):
  name: str
  age: int

  # Define how the node is displayed in the database
  loomi_config = {
    "labels": {"Human", "Child"}
  }


class Adult(Node):
  name: str
  age: int
  job: str


class FamilyRelation(Relationship):
  loves_child: bool = Field(default=True)

  # Define how the relationship is displayed in the database
  loomi_config = {
    "type": "IS_PARENT_OF"
  }

2. Connect and query

import asyncio
import neo4j
from loomi import AsyncClient

# Initialize the driver like usual
driver = neo4j.AsyncGraphDatabase.driver(
  uri="bolt://localhost:7687", auth=("neo4j", "password")
)
client = AsyncClient(driver)

# Register models which the client should resolve
client.register(Child, Adult, FamilyRelation)

async def main():
  await client.initialize()

  async with client.session() as session:
    # Create some sample data
    await session.run(
      "CREATE (a:Adult $adult)-[r:IS_PARENT_OF $relation]->(c:Human:Child $child)",
      {
        "adult": {
          "name": "John",
          "age": 28,
          "job": "Developer"
        },
        "child": {
          "name": "Holly",
          "age": 5,
        },
        "relation": {
          "loves_child": True
        }
      }
    )

    # Query the database like you would usually
    result = await session.run(
      "MATCH (a:Adult)-[r:IS_PARENT_OF]->(c:Human:Child) RETURN a, c"
    )

    # `result` provides the same interface as the native result
    # with some loomi-specific additions
    models = await result.values()

    # Prints [[<Adult element_id='...' labels={'Adult'}>, <Child element_id='...' labels={'Child', 'Human'}>]]
    print(models)


if __name__ == "__main__":
  asyncio.run(main())

Local development & testing

This project uses Poetry to manage dependencies and virtual environments.

1. Setup environment

git clone [https://github.com/yourusername/loomi.git](https://github.com/yourusername/loomi.git)
cd loomi

poetry install
poetry run pre-commit install

2. Run database containers

docker compose up -d

3. Run the test suite

The following environment variables must be set in order to run all tests:

  • NEO4J_URI
  • NEO4J_USER
  • NEO4J_PWD=
  • MEMGRAPH_URI
  • MEMGRAPH_USER
  • MEMGRAPH_PWD
poetry run pytest --envfile .env.test tests/

Metadata

Release files for loomi 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for loomi 1.1.0
File Size Uploaded
loomi-1.1.0.tar.gz 38.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for loomi 1.1.0
File Interpreter ABI Platform
loomi-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 95.7 kB

Release files / loomi-1.1.0.tar.gz

Download URL loomi-1.1.0.tar.gz
Size 38.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e73190628b2f1ec1c5c76f8f265318ea0229fb9613df0b9933ef364ff8a68bfa
BLAKE2b-256 checksum
How to use checksums
83798b2053854667ff108b81f2c4a23008e1e03a456cf9a7b254af3f6e0f650a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release files / loomi-1.1.0-py3-none-any.whl

Download URL loomi-1.1.0-py3-none-any.whl
Size 57.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
283d68dac91d74ee7a5ecc12771225929fdde0870c150429cbe935d487c46499
BLAKE2b-256 checksum
How to use checksums
1014623fbaad86fd1a669e6829bc2ffb3d4eacac2a0fa3cc7f8ea4ad95916cf8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page