Skip to main content

A graph based queryable object persistance framework built on top of Neo4j.

Build status

https://secure.travis-ci.org/onefinestay/kaiso.png?branch=master

Example

In addition to objects, Kaiso also stores the class information in the graph. This allows us to use cypher to query instance information, but also to answer questions about our types.

Let’s define some basic classes

from kaiso.attributes import Integer, Outgoing, String, Uuid
from kaiso.types import Entity, Relationship


# define a simple type hierarchy

class Knows(Relationship):
    pass


class Animal(Entity):
    id = Uuid(unique=True)
    name = String()
    knows = Outgoing(Knows)


class Carnivore(Animal):
    pass


class Herbivore(Animal):
    pass


class Penguin(Herbivore):
    favourite_ice_cream = String()


class Lion(Carnivore):
    n_siblings = Integer()

As with any orm, we can make some instances and persist them in our graph

from kaiso.persistence import Manager

manager = Manager("http://localhost:7474/db/data/")


# create some instances

fred = Penguin(name="Fred")
tom = Lion(name="Tom")

relation = Knows(fred, tom)

manager.save(fred)
manager.save(tom)
manager.save(relation)

Using the Neo4j web interface to explore our graph, we find Tom and Fred:

docs/images/instances.png

However, in addition, we can also see the type information in the graph:

docs/images/type_hierarchy.png

We can make use of the type information in our queries, e.g. to find all herbivores who know a carnivore

MATCH
    (Herbivore:PersistableType {id: "Herbivore"}),
    (Carnivore:PersistableType {id: "Carnivore"}),
    Carnivore <-[:ISA*]-()<-[:INSTANCEOF]-(carnivore),
    Herbivore <-[:ISA*]-()<-[:INSTANCEOF]-(herbivore),

    (herbivore)-[:KNOWS]->(carnivore)

RETURN
    "The herbivore",
    herbivore.name,
    "knows the carnivore",
    carnivore.name;
==> +---------------------------------------------------------------------+
==> | "The herbivore" | "Fred"      | "knows the carnivore" | "Tom"       |
==> +---------------------------------------------------------------------+

Release files for kaiso 0.40.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 kaiso 0.40.0
File Size Uploaded
kaiso-0.40.0.tar.gz 32.0 kB Details

Release files / kaiso-0.40.0.tar.gz

Download URL kaiso-0.40.0.tar.gz
Size 32.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9cb3edddc45f94955cdac76258c3b5eda95cf122e8d3b685a0a5334ad34af855
BLAKE2b-256 checksum
How to use checksums
799008499560aa92ac87134220e0842742d6a52c605aef348cd34002716dc588
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.40.0 This release

1 release file

0.30.2

1 release file

0.30.1

1 release file

0.30.0

1 release file

0.23.0

1 release file

0.22.0

1 release file

0.21.0

1 release file

0.20.1

1 release file

0.20.0

1 release file

0.17.1

1 release file

0.17.0

1 release file

0.16.2

1 release file

0.16.1

1 release file

0.16.0

1 release file

0.15.2

1 release file

0.15.1

1 release file

0.15.0

1 release file

0.14.3

1 release file

0.14.2

1 release file

0.14.1

1 release file

0.14.0

1 release file

0.13.4

1 release file

0.13.3

1 release file

0.13.2

1 release file

0.13.1

1 release file

0.13.0

1 release file

0.12.0

1 release file

0.10.0

1 release file

0.9.0

1 release file

0.8.4

1 release file

0.8.3

1 release file

0.8.2

1 release file

0.8.1

1 release file

0.8.0

1 release file

0.7.0

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.2

1 release file

0.1.1

1 release file

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