KuzuDriver class provides connectivity to Kuzu, an embedded graph database optimized for analytical workloads.
Overview
Kuzu is an embeddable graph database designed for analytical queries and graph analytics. The KuzuDriver provides:- Embedded database (no separate server required)
- In-memory or disk-based storage
- Explicit schema with predefined node and edge types
- Concurrent query execution
- Zero-configuration setup for development
Constructor
Parameters
str
default:":memory:"
The database path or
:memory: for in-memory storage.Options:":memory:"- In-memory database (lost on process exit)"/path/to/db"- Persistent disk-based database
"./data/graphiti.kuzu" or ":memory:"int
default:"1"
Maximum number of concurrent queries allowed.Kuzu supports concurrent reads but serializes writes. Set higher for read-heavy workloads.Example:
4 for multi-threaded read queriesMethods
execute_query
Execute a Cypher query and return results.cypher_query_(str) - The Cypher query to execute**kwargs- Query parameters (None values are filtered out)
tuple[list[dict] | list[list[dict]], None, None] - Records as dictionaries
Kuzu does not support the
database_ and routing_ parameters. These are automatically removed from kwargs.session
Create a new database session._database(str | None) - Ignored for Kuzu (single database per driver)
KuzuDriverSession - Session object
close
Close the driver connection.None
Kuzu relies on garbage collection for cleanup. The close method is a no-op but is provided for interface compatibility.
build_indices_and_constraints
Required by the abstract base class, but a no-op for Kuzu.delete_existing(bool) - Ignored for Kuzu
None
Kuzu uses a predefined schema created during initialization. Indices are not dynamically created like Neo4j or FalkorDB.
setup_schema
Initialize the Kuzu database schema.None
This method is automatically called during driver initialization. You typically don’t need to call it manually.
Properties
provider
GraphProvider.KUZU enum value.
Operations Properties
The driver exposes specialized operation interfaces:Kuzu Schema
Kuzu requires an explicit schema defined upfront. The KuzuDriver automatically creates:Node Tables
- Episodic - Episode nodes with content and metadata
- Entity - Entity nodes with embeddings and attributes
- Community - Community nodes with embeddings and summaries
- Saga - Saga nodes for grouping episodes
- RelatesToNode_ - Helper nodes for edge properties (Kuzu workaround)
Relationship Tables
- RELATES_TO - Entity relationships (via RelatesToNode_)
- MENTIONS - Episodic mentions of entities
- HAS_MEMBER - Community membership
- HAS_EPISODE - Saga to episode links
- NEXT_EPISODE - Sequential episode ordering
Kuzu does not support fulltext indices on edge properties. The driver works around this by representing entity edges as:
(Entity)-[:RELATES_TO]->(RelatesToNode_)-[:RELATES_TO]->(Entity)Usage Examples
In-Memory Database
Persistent Database
With Graphiti
OpenTelemetry Integration
Concurrent Queries
Schema Inspection
Development and Testing
Kuzu is ideal for development and testing:Limitations
Performance Characteristics
- Fast analytical queries - Optimized for graph analytics
- Low memory overhead - Efficient in-memory representation
- Sequential writes - Writes are serialized, not ideal for high write throughput
- Concurrent reads - Multiple queries can read simultaneously
- Columnar storage - Efficient for scanning large datasets
When to Use Kuzu
Use KuzuDriver for:- Development and testing
- Embedded applications
- Analytical workloads
- In-memory processing
- Single-process deployments
- CI/CD pipelines (fast, no server required)
- Production multi-tenant systems → Neo4j or FalkorDB
- High write throughput → Neo4j
- Cloud deployments → Neptune
- Distributed systems → Neo4j
Related
Drivers Overview
Learn about the driver architecture
Graphiti
Main Graphiti class documentation
Neo4j Driver
Production-ready driver with transactions
FalkorDB Driver
Redis-based multi-tenant driver