summaryrefslogtreecommitdiff
path: root/litedb/query.ml
diff options
context:
space:
mode:
Diffstat (limited to 'litedb/query.ml')
-rw-r--r--litedb/query.ml16
1 files changed, 16 insertions, 0 deletions
diff --git a/litedb/query.ml b/litedb/query.ml
index 61616b4..37530db 100644
--- a/litedb/query.ml
+++ b/litedb/query.ml
@@ -103,3 +103,19 @@ let sqlite_pragmas = [
"PRAGMA synchronous = NORMAL";
"PRAGMA mmap_size = 30000000000";
]
+
+(* Example of how to execute raw SQL with Caqti *)
+let init_connection conn =
+ let module C = (val conn : Rapper_helper.CONNECTION) in
+ (* Create a request: unit input -> unit output using Caqti infix operators *)
+ let pragma_req sql =
+ let open Caqti_request.Infix in
+ let open Caqti_type in
+ (unit ->. unit) sql
+ in
+ (* Execute each pragma *)
+ List.fold_left (fun acc sql ->
+ match acc with
+ | Error e -> Error e
+ | Ok () -> C.exec (pragma_req sql) ()
+ ) (Ok ()) sqlite_pragmas