Minimal SQLite key-value store for OCaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocaml-sqlite: rewrite README example to typecheck

The block had a missing newline before [Sqlite.Table.put] (running
the [create] line into the next call) and free [fs]. Wrap as
[run ~fs = ...], assert the [Sqlite.find] roundtrip, and add
[eio.core] to the mdx libraries.

+15 -16
+14 -15
README.md
··· 33 33 ## Usage 34 34 35 35 ```ocaml 36 - (* Open or create a database *) 37 - Eio.Switch.run @@ fun sw -> 38 - let db = Sqlite.open_ ~sw (Eio.Path.(fs / "data.db")) 39 - (* Basic key-value operations *) 40 - Sqlite.put db "key1" "value1"; 41 - let value = Sqlite.find db "key1" in (* Some "value1" *) 42 - 43 - (* Namespaced tables *) 44 - let blocks = Sqlite.Table.create db ~name:"blocks"Sqlite.Table.put blocks "cid1" "data1"; 45 - 46 - (* Sync to disk *) 47 - Sqlite.sync db; 48 - 49 - (* Close when done *) 50 - Sqlite.close db 36 + let run ~fs = 37 + Eio.Switch.run @@ fun sw -> 38 + (* Open or create a database. *) 39 + let db = Sqlite.open_ ~sw Eio.Path.(fs / "data.db") in 40 + (* Basic key-value operations. *) 41 + Sqlite.put db "key1" "value1"; 42 + assert (Sqlite.find db "key1" = Some "value1"); 43 + (* Namespaced tables. *) 44 + let blocks = Sqlite.Table.create db ~name:"blocks" in 45 + Sqlite.Table.put blocks "cid1" "data1"; 46 + (* Sync to disk. *) 47 + Sqlite.sync db; 48 + (* Close when done. *) 49 + Sqlite.close db 51 50 ``` 52 51 53 52 ## API
+1 -1
dune
··· 4 4 5 5 (mdx 6 6 (files README.md) 7 - (libraries sqlite eio eio.unix)) 7 + (libraries sqlite eio eio.core eio.unix))