File: sql.ml

package info (click to toggle)
pplacer 1.1~alpha19-8
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 17,324 kB
  • sloc: ml: 20,927; ansic: 9,002; python: 1,641; makefile: 171; sh: 77; xml: 50
file content (23 lines) | stat: -rw-r--r-- 506 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
open Sqlite3
module D = Sqlite3.Data

let check ?(allowed = [Rc.OK]) db retcode =
  if not (List.mem retcode allowed) then
    raise (Error (errmsg db))

let check_exec db ?cb ?allowed s =
  check ?allowed db (exec ?cb db s)

let bind_arr ?allowed db st arr =
  Array.iteri
    (fun e x -> check ?allowed db (bind st (e + 1) x))
    arr

let bind_step_reset db st params =
  bind_arr db st params;
  check ~allowed:[Rc.DONE] db (step st);
  check db (reset st)

let close db =
  let _ = db_close db in ()