Expand description
SQLite-based graph database with unified backend support.
sqlitegraph provides a lightweight, deterministic graph database for embedded Rust applications. It supports both SQLite and Native storage backends through a unified API.
§Features
- Dual Backend Support: Choose between SQLite (feature-rich) and Native (performance-optimized) backends
- Entity and Edge Storage: Rich metadata support with JSON serialization
- Pattern Matching: Efficient triple pattern matching with cache-enabled fast-path
- Traversal Algorithms: Built-in BFS, k-hop, and shortest path algorithms
- MVCC Snapshots: Read isolation with snapshot consistency
- Bulk Operations: High-performance batch insertions for large datasets
- Configuration: Runtime backend selection with fine-grained options
§Quick Start
ⓘ
use sqlitegraph::{open_graph, GraphConfig, BackendKind};
// Use SQLite backend (default)
let cfg = GraphConfig::sqlite();
let graph = open_graph("my_graph.db", &cfg)?;
// Or use Native backend
let cfg = GraphConfig::native();
let graph = open_graph("my_graph.db", &cfg)?;
// Both backends support the same operations
let node_id = graph.insert_node(/* node spec */)?;
let neighbor_ids = graph.neighbors(node_id, /* query */)?;§Backend Selection
§SQLite Backend (Default)
- ACID transactions with rollback support
- Complex queries beyond basic graph operations
- Standard SQLite file format and tooling
- Mature ecosystem and compatibility
§Native Backend
- Optimized for graph operations
- Simplified deployment without SQLite dependencies
- Fast startup with large datasets
- Custom binary format for graph data
§Public API Organization
This crate exports a clean, stable public API organized as follows:
§Core Types
GraphEntity- Graph node/vertex representationGraphEdge- Graph edge/relationship representationGraphBackend- Unified trait for backend implementationsSqliteGraphBackend- SQLite backend implementationNativeGraphBackend- Native backend implementation
§Configuration
BackendKind- Runtime backend selection enumGraphConfig- Unified configuration for both backendsSqliteConfig- SQLite-specific optionsNativeConfig- Native-specific optionsopen_graph()- Unified factory function
§Operations
- [
insert_node()], [insert_edge()] - Single entity/edge insertion bulk_insert_entities(), [bulk_insert_edges()- Batch operations- [
neighbors()] - Direct neighbor queries - [
bfs()], [k_hop()], [shortest_path()] - Graph traversal algorithms pattern_engine- Pattern matching and triple storage
§Utilities
SqliteGraphError- Comprehensive error handlingGraphSnapshot- MVCC snapshot systemrecovery- Database backup and restore utilitiesquery::GraphQuery- High-level query interface
Re-exports§
pub use graph_opt::GraphEdgeCreate;pub use graph_opt::GraphEntityCreate;pub use graph_opt::bulk_insert_edges;pub use graph_opt::bulk_insert_entities;pub use graph_opt::cache_stats;pub use index::add_label;pub use index::add_property;pub use mvcc::GraphSnapshot;pub use mvcc::SnapshotState;pub use pattern_engine::PatternTriple;pub use pattern_engine::TripleMatch;pub use pattern_engine::match_triples;pub use query::GraphQuery;pub use recovery::dump_graph_to_path;pub use recovery::load_graph_from_path;pub use recovery::load_graph_from_reader;pub use backend::BackendDirection;pub use backend::ChainStep;pub use backend::GraphBackend;pub use backend::EdgeSpec;pub use backend::NativeGraphBackend;pub use backend::NeighborQuery;pub use backend::NodeSpec;pub use backend::SqliteGraphBackend;pub use config::BackendKind;pub use config::GraphConfig;pub use config::NativeConfig;pub use config::SqliteConfig;pub use config::open_graph;pub use errors::SqliteGraphError;pub use graph::GraphEdge;pub use graph::GraphEntity;pub use graph::SqliteGraph;pub use cache::CacheStats;
Modules§
- algo
- backend
- Backend trait bridging sqlitegraph with higher-level graph consumers.
- backend_
selector - bench_
gates - bench_
meta - bench_
regression - bench_
utils - bfs
- cache
- config
- Configuration for backend selection and backend-specific options.
- dsl
- errors
- graph
- SQLite-backed graph database implementation.
- graph_
opt - hnsw
- Hierarchical Navigable Small World (HNSW) Vector Search
- index
- multi_
hop - mvcc
- MVCC-lite snapshot system for SQLiteGraph
- pattern
- pattern_
engine - Lightweight triple pattern matcher for SQLiteGraph.
- query
- query_
cache - High-level query cache layer for SQLiteGraph.
- recovery
- schema
Macros§
- checkpoint_
error - Macro for creating checkpoint errors with context
- recovery_
error
Structs§
Functions§
- match_
triples_ fast - Execute cache-enabled fast-path pattern matching.