| Crates.io | hanzo-database |
| lib.rs | hanzo-database |
| version | 1.1.12 |
| created_at | 2025-11-29 17:26:04.87199+00 |
| updated_at | 2026-01-07 22:31:45.061839+00 |
| description | Multi-backend database abstraction for Hanzo Node - Supports LanceDB, DuckDB, PostgreSQL, and more |
| homepage | https://hanzo.ai |
| repository | https://github.com/hanzoai/hanzo-node |
| max_upload_size | |
| id | 1957101 |
| size | 383,522 |
A unified database abstraction layer for Hanzo Node that supports multiple backend databases, each optimized for different workloads.
| Backend | Best For | Features |
|---|---|---|
| LanceDB | Vector Search, AI/ML | • Native vector operations • Multimodal storage • Columnar format • Fast similarity search |
| DuckDB | Analytics, OLAP | • In-process analytical database • SQL support • Columnar storage • Fast aggregations |
| PostgreSQL | Transactional, OLTP | • ACID compliance • Rich SQL features • Extensions (pgvector) • Battle-tested |
| Redis | Caching, Real-time | • In-memory storage • Pub/sub support • TTL/expiration • Extremely fast |
| SQLite | Embedded, Lightweight | • Zero-configuration • Single file • Serverless • Wide compatibility |
use hanzo_db::{connect, HanzoDbConfig, DatabaseBackend, WorkloadType};
// Automatically select backend based on workload
let config = HanzoDbConfig {
backend: DatabaseBackend::for_workload(WorkloadType::VectorSearch),
..Default::default()
};
// Or explicitly choose a backend
let config = HanzoDbConfig {
backend: DatabaseBackend::LanceDB,
path: Some("./data/vectors".into()),
..Default::default()
};
let db = connect(config).await?;
// Use unified interface regardless of backend
db.create_table("embeddings", schema).await?;
db.insert("embeddings", &records).await?;
let results = db.vector_search(query).await?;
# Select default backend
HANZO_DB_BACKEND=lancedb # lancedb, duckdb, postgresql, redis, sqlite
# Backend-specific configuration
HANZO_DB_PATH=./storage/hanzo-db
HANZO_DB_URL=postgresql://user:pass@localhost/hanzo
HANZO_REDIS_URL=redis://localhost:6379
[dependencies]
hanzo_db = { version = "1.0", features = ["lancedb", "duckdb", "postgres"] }
Migrate from one backend to another:
# From SQLite to LanceDB
hanzo-migrate --from sqlite://old.db --to lancedb://./vectors
# From LanceDB to PostgreSQL
hanzo-migrate --from lancedb://./vectors --to postgresql://localhost/hanzo
| Operation | LanceDB | DuckDB | PostgreSQL | Redis | SQLite |
|---|---|---|---|---|---|
| Vector Search | ⭐⭐⭐⭐⭐ | ⭐⭐ | ⭐⭐⭐ | ⭐ | ⭐ |
| Analytics | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐ | ⭐⭐ |
| Transactions | ⭐⭐⭐ | ⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐ | ⭐⭐⭐⭐ |
| Caching | ⭐⭐ | ⭐ | ⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐ |
| Embedded | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐ | ⭐ | ⭐⭐⭐⭐⭐ |
Apache 2.0