Plenty of programs need two things from their data. Fast key lookups, thousands of times a second, and SQL for the totals, filters and joins. The usual answer is two stores: a key-value store like RocksDB or Redis next to SQLite. Then the data lives twice, code has to keep both copies in step, and a change can’t be atomic across both.
KvSQL keeps one copy. It has a “key door” and an “SQL door” onto the same records. The key door reads and writes rows straight on the storage tree, with no parsing or planning. The SQL door parses and plans a query, then reads the same bytes. Both share one file, one transaction and the same indexes, and the indexes stay correct no matter which door wrote the row.
The Pitch in Four Numbers
- 20,000 simulated power cuts, with no commit lost or torn.
- 30,000 random SQL statements, every answer the same as SQLite’s.
- 100 kills of a busy server, with every confirmed write still there.
- 0 external dependencies in the engine, only the Rust standard library.
Two Products on One Set of Records
KvSQL Engine is an embeddable Rust library that stores everything in one file, with no server. KvSQL DB is the server, kvsqld, which serves one file over HTTP with JSON, plus the kvsql shell that connects to the server or opens a file directly. Each server request is one transaction, and a write is acknowledged only once it’s on disk.
How It Works
Under the hood there’s a copy-on-write B+tree per keyspace and two alternating meta pages, checked by a commit record when the file opens. The main promise is simple: a commit that returned is never lost, and a crash leaves either the whole commit or none of it. Readers work from snapshots and never wait for the writer. There’s one writer at a time.
The SQL covers CREATE TABLE and INDEX, INSERT, UPDATE, DELETE, and SELECT with joins, WHERE, GROUP BY, HAVING, ORDER BY and LIMIT. NULL handling and comparisons between text and numbers follow SQLite’s rules, which is why the test suite can check 30,000 random statements against SQLite and expect identical answers.
Before release, an independent reviewer who hadn’t seen the code went looking for bugs, and every confirmed finding was fixed and tested. Releases are built in CI and ship only after tests and a smoke test pass on Linux, macOS and Windows.
Where It Fits
The project’s examples show the kinds of jobs it’s made for: a checkout that’s never half done, tested with 1,200 power cuts; an edge gateway collecting sensor readings over HTTP with kvsqld; sessions and reporting in one store instead of two; a cache with expiry, using key reads plus an SQL sweep to clear old entries.
Who It’s For
- Rust developers who want an embedded store with both fast keys and real SQL.
- Teams running Redis or RocksDB next to SQLite who are tired of keeping them in step.
- Edge and gateway builders who need a small, crash-safe server they can reach over HTTP.
- Anyone who needs atomic changes across lookup data and reporting data.
Limits
One writer at a time, and on the server each request is its own transaction. The SQL is a solid subset, not all of SQL, and the reference lists what is and isn’t supported. The project publishes its benchmarks against SQLite and other embedded stores, and is straightforward that in some of them the others are faster.
The Four-Question Screening
Every project featured here gets the same four questions, the way you’d screen a startup idea.
1. Where is the money in it?
Both products are open source under Apache 2.0, with no paid tier. Embedded databases make money the way SQLite’s world does: support contracts, long-term maintenance and certified builds for companies that ship them inside their own products. KvSQL DB adds a second path, a managed or hosted server for small apps and edge deployments, and paid features like replication and backup that a single-file database eventually needs.
2. What real problem does it solve?
Two copies of the same data. Pairing a key-value store with a SQL database means sync code, drift and changes that can’t be made all at once. A crash halfway leaves the two disagreeing. KvSQL removes the second copy and the sync code with it.
3. The technology in plain words
Think of a library with two ways in. The front desk, where you hand over a number and get the exact book back straight away. And the reading room, where you can ask a librarian complicated questions like “every book on Rome published after 1990.” Both doors lead to the same shelves. KvSQL builds the library so there’s only one set of shelves, and nothing has to be copied between them.
4. Moat and differentiation
There are good embedded key-value stores in Rust, and good SQL engines. Few put both doors on one storage tree with one transaction and indexes that stay right whichever door you use. The test record, power cuts, killed servers and tens of thousands of statements matched against SQLite, is what turns that into something people can trust. The moat that can grow is that record, plus the edge and gateway use cases where a small, crash-safe server with both access paths has few rivals.
Why It Matters
A lot of everyday software is held together by glue code that keeps two databases in step. Every line of it is a place for bugs to hide. One store with two doors makes that glue unnecessary.
Follow the Project
Read why key lookups and SQL belong on the same records, start with the quick start, see how KvSQL was tested, or get the code from the KvSQL repository on GitHub. KvSQL is listed with the other open-source projects on SoftDevStudio.com, and more featured projects are in the Projects section.