···4455## Overview
6677-A simple key-value store backed by SQLite with support for:
77+A pure OCaml key-value store that reads and writes the SQLite file format,
88+backed by a B-tree implementation. Supports:
89- Namespaced tables for organizing data
910- WAL mode for concurrent access
1011- Efficient batch operations
···20212122```ocaml
2223(* Open or create a database *)
2323-let db = Sqlite.create (Eio.Path.(fs / "data.db")) in
2424+Eio.Switch.run @@ fun sw ->
2525+let db = Sqlite.open_ ~sw (Eio.Path.(fs / "data.db")) in
24262527(* Basic key-value operations *)
2628Sqlite.put db "key1" "value1";
2727-let value = Sqlite.get db "key1" in (* Some "value1" *)
2929+let value = Sqlite.find db "key1" in (* Some "value1" *)
28302931(* Namespaced tables *)
3032let blocks = Sqlite.Table.create db ~name:"blocks" in
···41434244### Database
43454444-- `Sqlite.create path` - Open or create a SQLite database at path
4545-- `Sqlite.get db key` - Get value for key, or None
4646+- `Sqlite.open_ ~sw ?create path` - Open or create a SQLite database at path
4747+- `Sqlite.find db key` - Get value for key, or None
4648- `Sqlite.put db key value` - Store value at key
4749- `Sqlite.delete db key` - Remove key
4850- `Sqlite.mem db key` - Check if key exists
···58605961## Related Work
60626161-- [sqlite3-ocaml](https://github.com/mmottl/sqlite3-ocaml) - Low-level SQLite3 bindings (used internally)
6363+- [sqlite3-ocaml](https://github.com/mmottl/sqlite3-ocaml) - Low-level SQLite3 C bindings
6264- [ezsqlite](https://opam.ocaml.org/packages/ezsqlite/) - Alternative SQLite bindings with extensions
6365- [irmin](https://github.com/mirage/irmin) - Git-like distributed database (different use case)
64666565-## Future: Pure OCaml Implementation
6767+## Pure OCaml Implementation
66686767-The current implementation uses C bindings via sqlite3-ocaml. A future pure OCaml
6868-implementation would enable:
6969+This implementation is written in pure OCaml using a B-tree backend. This enables:
6970- Unikernel deployment (MirageOS, Solo5)
7071- Browser targets via js_of_ocaml
7172- Full control over I/O with bytesrw streaming