package granary
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
Pure-OCaml SQL engine
Install
dune-project
Dependency
Authors
Maintainers
Sources
0.0.3.tar.gz
sha256=8b18780ea373be48301d9f333925860a2f9110fc0ac28684295118d72b65a67e
sha512=25ca3c9c5e2b528704a542502e0f37dc33ba003f65622d969b8c2b800778585f8ef0cf89b36e6679832e3993e8303aecddfc662742baf7044d6afe4a796b8f11
doc/src/granary.sample/sample.ml.html
Source file sample.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27module Db = Granary.Db (* Result-aware bind over an [(_, _) result Lwt.t]: short-circuits on the first [Error] so the workload reads as a flat sequence (keeps merlint nesting low). *) let ( let*? ) (m : ('a, 'e) result Lwt.t) (f : 'a -> ('b, 'e) result Lwt.t) : ('b, 'e) result Lwt.t = Lwt.bind m (function | Ok x -> f x | Error e -> Lwt.return_error e) ;; let run_demo db = let exec sql = Db.execute db sql in let*? () = exec "CREATE TABLE kv (id INTEGER PRIMARY KEY, name TEXT NOT NULL)" in let*? () = exec "BEGIN" in let*? () = exec "INSERT INTO kv (id, name) VALUES (1, 'alpha')" in let*? () = exec "INSERT INTO kv (id, name) VALUES (2, 'beta')" in let*? () = exec "INSERT INTO kv (id, name) VALUES (3, 'gamma')" in let*? () = exec "COMMIT" in let*? stream = Db.query db "SELECT id, name FROM kv ORDER BY id" in Lwt.bind (Lwt_stream.to_list stream) (fun rows -> Lwt.return_ok (List.length rows)) ;; [@@@ai_disclosure "ai-generated"] [@@@ai_model "claude-opus-4-8"] [@@@ai_provider "Anthropic"]
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>