Welcome to Runic

Graph schema migrations and OGM for Cypher-based graph databases.

PyPI GitHub Python Support License


runic ships two tools:

  • runic.ogm — a lightweight, graph-optimized OGM that maps Python classes to graph nodes and edges. Supports FalkorDB, ArcadeDB, Neo4j, Memgraph, Apache AGE (PostgreSQL), and any Bolt-compatible database via a pluggable driver layer.

  • runic.migrate — an Alembic-style migration engine that tracks index and constraint changes as versioned, replayable scripts.

from runic.ogm import Field, Node, Repository, Session, create_driver

class Person(Node, labels=["Person"]):
    id: str = Field()
    name: str = Field()
    email: str = Field(index=True, unique=True)

with Session(driver) as session:
    session.add(Person(id="alice", name="Alice", email="alice@example.com"))
    session.commit()

    repo = Repository(session, Person)
    print(repo.count())   # 1

OGM

OGM quickstart

Define your first node, open a session, and persist it in under a minute.

Quickstart
Define your models

Declare nodes, edges, fields, and relationships — with types, indexes, and constraints.

Define your models
Model connections

Lazy/eager loading, polymorphic hierarchies, edge properties.

Relationships
Read and write data

add · delete · get · flush · commit · rollback · expire.

Read and write data
Query your graph

Fluent filter, traversal, aggregation, fulltext and vector KNN API.

Query Builder
Async guide

AsyncSession, no-lazy rules, async CRUD, repositories, and testing.

Async Guide
Test your code

Embedded FalkorDB, pytest fixtures, isolation patterns, and gotchas.

Test your OGM code
Choose a backend

FalkorDB, ArcadeDB, Neo4j, Memgraph, AGE — feature matrix and limits.

Supported Drivers
OGM API reference

Full autodoc reference for every public class and function.

OGM API Reference

Migration

Migration quickstart

Install runic, run runic init, write your first migration, and apply it — all in one page.

Quickstart
OGM + Migration guide

Three-stage workflow, Field→op table, ordering rules, and 7 annotated patterns.

OGM and Migrations
CLI reference

Every command, option, and flag documented with examples.

CLI Reference
Operations reference

Full list of op.* calls available inside migration scripts.

Operations Reference
Schema management

IndexManager and SchemaManager — declare, validate, and sync indexes.

Schema management
Migration API reference

runic.migrate — programmatic migration engine API.

Migration API Reference