Skip to main content

Knowledge graph + vector search + SQL analytics powered by DuckDB

Project description

ChimeraDB

Semantic search + graph queries + SQL analytics. All in one DuckDB file.

The only database that combines vector embeddings, property graphs (SQL/PGQ), and full SQL analytics for LLM apps. No separate vector DB, no separate graph DB, no infrastructure.

Python 3.8+ License: MIT

ExamplesDocs


Quick Start

pip install chimeradb duckdb
from chimeradb import KnowledgeGraph

kg = KnowledgeGraph("my.db")  # Auto-embeddings enabled

# Add entities (embeddings generated from 'bio' field)
kg.add_entity("alice", {"name": "Alice", "bio": "ML engineer building LLM agents"}, ["Person"])
kg.add_entity("bob", {"name": "Bob", "bio": "AI researcher focused on NLP"}, ["Person"])
kg.add_entity("acme", {"name": "Acme AI"}, ["Company"])

# Add relationships
kg.add_relationship("alice", "acme", "WORKS_AT")
kg.add_relationship("bob", "acme", "WORKS_AT")

# 1. Semantic search - Find by meaning, not keywords
results = kg.search("who works on language models?", top_k=2)
# Finds both Alice and Bob even though query doesn't match exactly

# 2. Graph traversal - Python API
employees = kg.traverse("acme", direction="incoming")

# 3. SQL/PGQ - Graph pattern matching (SQL:2023 standard)
results = kg.query("""
    SELECT *
    FROM GRAPH_TABLE (knowledge_graph
        MATCH (p:nodes)-[e:edges]->(c:nodes)
        WHERE c.id = 'acme'
        COLUMNS (
            json_extract_string(p.properties, 'name') as person,
            e.edge_type
        )
    )
""")

# 4. SQL analytics - Aggregate, filter, join
stats = kg.query("""
    SELECT
        json_extract_string(n.properties, 'name') as company,
        COUNT(*) as employee_count
    FROM nodes n
    JOIN edges e ON e.to_id = n.id
    WHERE n.labels LIKE '%Company%'
    GROUP BY company
""")

# Combine all three in one query!
results = kg.query("""
    WITH relevant_people AS (
        -- Find semantically similar people (would use search() in practice)
        SELECT id, properties
        FROM nodes
        WHERE labels LIKE '%Person%'
    )
    SELECT
        json_extract_string(p.properties, 'name') as person,
        json_extract_string(c.properties, 'name') as company,
        e.edge_type
    FROM relevant_people p
    JOIN edges e ON e.from_id = p.id
    JOIN nodes c ON e.to_id = c.id
    WHERE c.labels LIKE '%Company%'
""")

Why ChimeraDB?

Three powerful tools, one simple database:

  1. Vector embeddings - Search by meaning, not keywords. Find "machine learning expert" when the text says "AI researcher"
  2. Property graphs - Express relationships naturally with SQL/PGQ: MATCH (person)-[edge]->(company)
  3. Full SQL analytics - Aggregate, filter, join with the full power of DuckDB

The combination is the killer feature:

  • RAG systems: Semantic search + relationship context
  • AI agents: Graph traversal + analytical reasoning
  • Recommendations: Similarity search + collaborative filtering

Zero infrastructure:

  • One DuckDB file
  • Runs anywhere (laptop, server, edge device)
  • 10-100x faster than other embedded options
  • Production-ready extensions (duckpgq, vss)

Installation

Python Package

pip install chimeradb duckdb

Platform Support:

  • ✅ macOS (Intel x86_64 & Apple Silicon ARM64)
  • ✅ Linux (x86_64)
  • ✅ Linux ARM64 (with DuckDB v1.1.3)
  • ⚠️ Windows: DuckDB extensions may need manual installation

Or from source:

git clone https://github.com/codimusmaximus/chimeradb.git
cd chimeradb
pip install -e .

DuckDB Extensions

ChimeraDB automatically installs these DuckDB extensions:

  • duckpgq: Property graph queries with SQL/PGQ
  • vss: Vector similarity search with HNSW indexing

Python API

from chimeradb import KnowledgeGraph

# Create database
kg = KnowledgeGraph("my_graph.db")  # Or ":memory:"

# Optional: disable embeddings or use different model
# kg = KnowledgeGraph("my.db", embedding_model=None)
# kg = KnowledgeGraph("my.db", embedding_model="text-embedding-3-small")

# Add nodes
kg.add_entity(
    entity_id="person1",
    properties={"name": "Alice", "bio": "AI researcher"},
    labels=["Person"],
    embed_field="bio"  # Auto-generate embedding from this field
)

# Add relationships
kg.add_relationship(
    from_id="person1",
    to_id="company1",
    relation_type="WORKS_AT",
    properties={"since": 2020}
)

# Semantic search
results = kg.search("machine learning expert", top_k=10)

# Graph traversal (recursive SQL)
network = kg.traverse("person1", direction="outgoing", max_depth=3)

# SQL/PGQ pattern matching
results = kg.query("""
    SELECT *
    FROM GRAPH_TABLE (knowledge_graph
        MATCH (p:nodes)-[w:edges]->(c:nodes)
        WHERE p.labels LIKE '%Person%'
          AND c.labels LIKE '%Company%'
        COLUMNS (p.id, w.edge_type, c.id)
    )
""")

# Raw SQL queries
data = kg.query("""
    SELECT json_extract(properties, '$.name') as name
    FROM nodes
    WHERE json_extract(properties, '$.role') = 'Engineer'
""")

kg.close()

Examples

Requirements

  • Python 3.8+
  • DuckDB 1.1.3+ (automatically installed with chimeradb)
  • sentence-transformers (for embeddings, auto-installed)

Documentation

Tech Stack

Built on:

Performance

DuckDB provides 10-100x better performance than traditional embedded databases for analytical queries:

  • Columnar storage for fast aggregations
  • Vectorized query execution
  • Zero-copy data access
  • Production-ready HNSW indexing

Migration from v0.1.x (SQLite)

ChimeraDB v0.2.0+ uses DuckDB instead of SQLite for better performance and reliability. Key changes:

Removed:

  • cypher() method - Use SQL/PGQ with query() instead
  • Cypher query language - Use SQL/PGQ (SQL:2023 standard)
  • SQLite extensions - Now use DuckDB extensions

New/Updated:

  • Property graphs use SQL/PGQ syntax
  • 10-100x faster for analytics
  • No corruption bugs from global state
  • Same Python API for add_entity(), add_relationship(), search(), traverse()

See SQL/PGQ documentation for graph query syntax.

License

MIT - see LICENSE

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

chimeradb-0.2.21.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

chimeradb-0.2.21-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file chimeradb-0.2.21.tar.gz.

File metadata

  • Download URL: chimeradb-0.2.21.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for chimeradb-0.2.21.tar.gz
Algorithm Hash digest
SHA256 5208b4a131261e6fb1dc7f437ce626652203757bb3f3b8b616d60eca37cd17a5
MD5 b8d0e98c55046a87f0f05a07a35c2e3d
BLAKE2b-256 e1c9f8a865556aaec94bb9acac77dfaf0d30accbd3699e2edf8093281b3b6cbf

See more details on using hashes here.

File details

Details for the file chimeradb-0.2.21-py3-none-any.whl.

File metadata

  • Download URL: chimeradb-0.2.21-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for chimeradb-0.2.21-py3-none-any.whl
Algorithm Hash digest
SHA256 f0fda475e984f47c3a293ca4654fbb1ea5f9b3552e0e7a7aa11891a1d7c395ce
MD5 4da86b1d3db5345cc6678073497facee
BLAKE2b-256 f12b11f3e5a0cf4d3fb26fc52629ba9bacac6531194b1302041b6e739f12c375

See more details on using hashes here.

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