prepare release 0.4.1
[sqlgg.git] / impl / sqlgg_traits.ml
blob93e00de50d36e9968c7abc05f01c1695e3f82ebc
1 (**
2 OCaml traits signature for sqlgg
3 by ygrek
4 2014-06-08
6 This is free and unencumbered software released into the public domain.
8 Anyone is free to copy, modify, publish, use, compile, sell, or
9 distribute this software, either in source code form or as a compiled
10 binary, for any purpose, commercial or non-commercial, and by any
11 means.
13 For more information, please refer to <http://unlicense.org/>
16 module type M = sig
18 type statement
19 type connection
20 type params
21 type row
22 type result
24 (** datatypes *)
25 type num = int64
26 type text = string
27 type any = text
28 type datetime = float
30 exception Oops of string
32 val get_column_Bool : row -> int -> bool
33 val get_column_Int : row -> int -> num
34 val get_column_Text : row -> int -> text
35 val get_column_Any : row -> int -> any
36 val get_column_Float : row -> int -> float
37 val get_column_Datetime : row -> int -> datetime
39 val start_params : statement -> int -> params
40 val finish_params : params -> result
42 (** [set_param_* stmt index val]. [index] is 0-based,
43 @raise Oops on error *)
44 val set_param_null : params -> int -> unit
45 val set_param_Text : params -> int -> text -> unit
46 val set_param_Any : params -> int -> any -> unit
47 val set_param_Bool : params -> int -> bool -> unit
48 val set_param_Int : params -> int -> num -> unit
49 val set_param_Float : params -> int -> float -> unit
50 val set_param_Datetime : params -> int -> datetime -> unit
52 val no_params : statement -> result
54 (**
55 Perform query and return results via callback for each row
56 @raise Oops on error
58 val select : connection -> string -> (statement -> result) -> (row -> unit) -> unit
60 (**
61 Perform query and return first row if available
62 @raise Oops on error
64 val select1 : connection -> string -> (statement -> result) -> (row -> 'b) -> 'b option
66 (** Execute non-query.
67 @raise Oops on error
68 @return number of affected rows
70 val execute : connection -> string -> (statement -> result) -> int64
72 end