No project description provided
Project description
loomi
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
neo4jpackage. 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
poetry run pytest tests/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file loomi-1.0.0.tar.gz.
File metadata
- Download URL: loomi-1.0.0.tar.gz
- Upload date:
- Size: 38.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b5ed06b47450951142f89b54762f069a044f97d14eb6a1925f3ac47cb798eae
|
|
| MD5 |
37f3c7696102c52564751bbeca313475
|
|
| BLAKE2b-256 |
bdf84c6f8771dd1b34983b2459ee884b83bae1fccd883be1a2c8652d90e39894
|
Provenance
The following attestation bundles were made for loomi-1.0.0.tar.gz:
Publisher:
release.yml on groc-prog/loomi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
loomi-1.0.0.tar.gz -
Subject digest:
7b5ed06b47450951142f89b54762f069a044f97d14eb6a1925f3ac47cb798eae - Sigstore transparency entry: 1625416299
- Sigstore integration time:
-
Permalink:
groc-prog/loomi@62af3b3014786f12388f499e54bf62d299536acb -
Branch / Tag:
refs/heads/main - Owner: https://github.com/groc-prog
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@62af3b3014786f12388f499e54bf62d299536acb -
Trigger Event:
push
-
Statement type:
File details
Details for the file loomi-1.0.0-py3-none-any.whl.
File metadata
- Download URL: loomi-1.0.0-py3-none-any.whl
- Upload date:
- Size: 57.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4fd026ddcd2700f078165873f1eab7ff3bb4bbb7d33835eab9043b5cdd27f67
|
|
| MD5 |
317bbfe9f5da97987576fcad25864207
|
|
| BLAKE2b-256 |
5e0a063a3f7da4ba4923e2fd2644ab273236c148c7765a6a99b92e01c6f7dbbe
|
Provenance
The following attestation bundles were made for loomi-1.0.0-py3-none-any.whl:
Publisher:
release.yml on groc-prog/loomi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
loomi-1.0.0-py3-none-any.whl -
Subject digest:
f4fd026ddcd2700f078165873f1eab7ff3bb4bbb7d33835eab9043b5cdd27f67 - Sigstore transparency entry: 1625416308
- Sigstore integration time:
-
Permalink:
groc-prog/loomi@62af3b3014786f12388f499e54bf62d299536acb -
Branch / Tag:
refs/heads/main - Owner: https://github.com/groc-prog
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@62af3b3014786f12388f499e54bf62d299536acb -
Trigger Event:
push
-
Statement type: