Skip to main content

A clean, embedded graph database engine for Python.

Project description

Graphite

A clean, embedded graph database engine for Python.


Graphite is a lightweight yet flexible graph database engine implemented in pure Python. It is designed to model graph-like data inside large Python codebases without introducing the complexity of an external database.


Features

🧩 Embedded by Design

Graphite is not a separate service or infrastructure dependency. It lives inside your project, evolves with it, and collaborates naturally with your existing code.

No servers. No ports. No deployment headaches.


🛠 Ready-made, Customizable Module

Graphite is intentionally simple and hackable. You can fork it, modify it, or deeply integrate it into your project without fighting rigid abstractions.

The database adapts to your project — not the other way around.


🐍 Native Python API

Everything is done through Python APIs. No query strings. DSL parsing is just an optional layer. No context switching.

Your editor already knows how to autocomplete and document your queries.


🔍 Query? It’s Code.

Queries are built by chaining Python functions on the QueryResult object.

  • Zero parsing cost
  • Full IDE support
  • Refactor-safe
  • Debuggable

🔄 Runtime Evolution

Change structures, data, or even engine behavior at runtime. No shutdowns. No migrations. No waiting.


🧱 Structure-Oriented Modeling

Define:

  • node types
  • relation types
  • fields
  • base types
  • valid forms

Model your domain explicitly and safely.


🧬 Node Inheritance

Create base node types and extend them with shared properties and advanced relationships.


✨ Simple, Predictable Syntax

From defining structures to querying data, every step favors clarity and minimal syntax.


💾 Serializable

Persist the entire database into a single file.


Installation

Install from PyPI:

pip install graphitedb

Why Graphite?

Graphite was extracted from a large production codebase where Neo4j introduced more complexity than value.

Neo4j is a powerful tool — but in large projects, adding a separate graph database often increases:

  • infrastructure complexity
  • deployment cost
  • maintenance burden
  • cognitive load on developers

Graphite exists for cases where this cost is not justified.

It provides graph modeling without adding another system to operate.

Comparation

Feature Neo4j Graphite Custom Graph Engine
Bug Safety 🥇Very High:
Mature & tested
🥈High:
Unit tests, monitored
🥉Low-Medium:
You manage testing
Implementation 🥈High:
Setup & Cypher
🥇Low:
Embed easily
🥉Very High:
Build from scratch
Flexibility 🥈High:
Complex queries
🥉Medium:
Limited but extendable
🥇Very High:
Fully customizable
Performance 🥇High:
Optimized large data
🥈Medium:
Good for small/medium
❓Unknown:
Depends on design
Scalability 🥇High:
Cluster & sharding
🥈Medium:
Single-node & Base types
❓Unknown:
Possible but hard
Support / Community 🥇Very High:
Large & active
🥈Medium:
Docstrings only
🥉Low:
Internal only
Customizability 🥉Low:
Limited to API
🥈High:
Open source
🥇Very High:
Full control
Ease of Use 🥈Medium:
Learn Cypher
🥇High:
Quick & simple
🥉Low:
Needs study & test

Example Usage

import graphite

def example_complete_dsl_loading():
    engine = graphite.engine()

    complete_dsl = """
    # Define node types
    node Person
        name: string
        age: int

    node User from Person
        id: string
        email: string

    node Object
    node Book from Object
        title: string
        n_pages: int

    node Car from Object
        model: string
        year: int

    # Define relation types
    relation FRIEND both
        Person - Person
        since: date

    relation OWNER reverse OWNED_BY
        Person -> Object
        since: date
        purchased_at: date

    relation AUTHOR reverse AUTHORED_BY
        Person -> Book
        year: int

    # Create nodes
    User, user_1, "Joe Doe", 32, "joe4030", "joe@email.com"
    User, user_2, "Jane Smith", 28, "jane28", "jane@email.com"
    User, user_3, "Bob Wilson", 45, "bob45", "bob@email.com"
    User, user_4, "Alice Brown", 22, "alice22", "alice@email.com"

    Book, book_1, "The Great Gatsby", 180
    Book, book_2, "Python Programming", 450
    Book, book_3, "Graph Databases", 320

    Car, car_1, "Toyota Camry", 2020
    Car, car_2, "Honda Civic", 2018

    # Create relations
    user_1 -[FRIEND, 2020-05-15]- user_2
    user_1 -[FRIEND, 2019-08-22]- user_3
    user_2 -[FRIEND, 2021-01-10]- user_4

    user_1 -[OWNER, 2021-03-01, 2021-02-15]-> car_1
    user_2 -[OWNER, 2019-06-20, 2019-05-10]-> book_1
    user_3 -[OWNER, 2022-11-05, 2022-10-20]-> book_2

    user_1 -[AUTHOR, 2020]-> book_3
    user_2 -[AUTHOR, 2021]-> book_2
    """

    engine.parse(complete_dsl)

    users = engine.query.User.get()
    print([u["name"] for u in users])

    return engine

More examples are available in examples/ in the GitHub repository.

See docs/ for documentation and API reference.


MIT 2026 Mahan Khalili

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

graphitedb-0.3.tar.gz (37.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

graphitedb-0.3-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

File details

Details for the file graphitedb-0.3.tar.gz.

File metadata

  • Download URL: graphitedb-0.3.tar.gz
  • Upload date:
  • Size: 37.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for graphitedb-0.3.tar.gz
Algorithm Hash digest
SHA256 41be860495dec91c5328b597f78799a29859ff38b0595cf43f7f82bc8981da34
MD5 91641c1eac63198b891c7e531855ebc4
BLAKE2b-256 7574d8861746f930901a0ef0754b07ca950eefe21476b9a759fa5c3d8c0ad7ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphitedb-0.3.tar.gz:

Publisher: python-publish.yml on mkh-user/graphite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file graphitedb-0.3-py3-none-any.whl.

File metadata

  • Download URL: graphitedb-0.3-py3-none-any.whl
  • Upload date:
  • Size: 24.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for graphitedb-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4aca48788ccef25d187702c6c9ab3a9459d69d11f973e0c9c451f96a179680f7
MD5 cefbb5e652abda09214d5f81da58dc3c
BLAKE2b-256 67a082eace7db800672dba8e823f3c6c4dc8996cdf12c6ac4c2728d907adca38

See more details on using hashes here.

Provenance

The following attestation bundles were made for graphitedb-0.3-py3-none-any.whl:

Publisher: python-publish.yml on mkh-user/graphite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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