impl/ocaml: add traits for float and datetime types (closes #12, closes #13)
[sqlgg.git] / impl / sqlgg_traits.ml
blob1184209d8c4d684bfa4b95b7b510d99c34dd1347
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_Int : row -> int -> num
33 val get_column_Text : row -> int -> text
34 val get_column_Any : row -> int -> any
35 val get_column_Float : row -> int -> float
36 val get_column_Datetime : row -> int -> datetime
38 val start_params : statement -> int -> params
39 val finish_params : params -> result
41 (** [set_param_* stmt index val]. [index] is 0-based,
42 @raise Oops on error *)
43 val set_param_null : params -> int -> unit
44 val set_param_Text : params -> int -> text -> unit
45 val set_param_Any : params -> int -> any -> unit
46 val set_param_Int : params -> int -> num -> unit
47 val set_param_Float : params -> int -> float -> unit
48 val set_param_Datetime : params -> int -> datetime -> unit
50 val no_params : statement -> result
52 (**
53 Perform query and return results via callback for each row
54 @raise Oops on error
56 val select : connection -> string -> (statement -> result) -> (row -> unit) -> unit
58 (**
59 Perform query and return first row if available
60 @raise Oops on error
62 val select1 : connection -> string -> (statement -> result) -> (row -> 'b) -> 'b option
64 (** Execute non-query.
65 @raise Oops on error
66 @return number of affected rows
68 val execute : connection -> string -> (statement -> result) -> int64
70 end