sqjson
sqjson is a simple, embedded, file-based key-value database using JSON values and memory-mapped files (like SQLite, but for JSON). It's written in pure Rust and has zero dependencies beyond serde, memmap2, and thiserror.
🚀 Features
- Lightweight and fast
- File-based — stores data in a single
.dbfile - JSON values for flexibility
- Key-based storage and retrieval
- Backed by memory-mapped I/O
- Easy to embed in any Rust project
📦 Installation
Add to your Rust project:
Or add manually to your Cargo.toml:
[]
= "0.1"
🛠 Usage
use ;
use json;
🔧 API Overview
| Method | Description |
|---|---|
YourDb::open() |
Open or create a database file |
put() |
Insert or update a key with a JSON value |
get() |
Retrieve a JSON value by key |
flush() |
Write index and pages to disk |
show_all() |
Print all key-value pairs (debug tool) |
📁 File Format
- Page 0: Stores the index (key → page ID)
- Page 1+: Stores actual JSON-encoded data
- Each page is fixed-size (
4096bytes default)
📃 License
MIT OR Apache-2.0
👤 Author
Made with ❤️ by [your name]