package mysql_protocol

  1. Overview
  2. Docs
type sign =
  1. | Positive
  2. | Negative

SQL columns data types.

type sql = private
  1. | Null
  2. | Tinyint of int
  3. | Smallint of int
  4. | Int of int
  5. | Longint of Stdlib.Int64.t
  6. | Longlongint of Big_int.big_int
  7. | Decimal of Num.num
  8. | Date of int * int * int
  9. | Time of sign * int * int * int * Stdlib.Int64.t
  10. | Datetime of (int * int * int) * (int * int * int * Stdlib.Int64.t)
  11. | Timestamp of (int * int * int) * (int * int * int * Stdlib.Int64.t)
  12. | Float of float
  13. | Double of float
  14. | Int24 of int
  15. | Year of int
  16. | Varchar of string
  17. | String of string
  18. | Varstring of string
  19. | Blob of Stdlib.Buffer.t
  20. | Binary of Stdlib.Buffer.t
  21. | Varbinary of Stdlib.Buffer.t
  22. | Enum of string
  23. | Set of string
  24. | Bit of Bitstring.t
  25. | Geometry of Bitstring.t
type t = sql
exception Wrong_type of string
val data_null : t

Build MySQL NULL value

val data_tinyint : int -> t

Build MySQL TINYINT value

val data_smallint : int -> t

Build MySQL SMALLINT value

val data_int : int -> t

Build MySQL INT value

val data_longint : Stdlib.Int64.t -> t

Build MySQL INT value

val data_longlongint : Big_int.big_int -> t

Build MySQL BIGINT value

val data_decimal : Num.num -> t

Build MySQL DECIMAL value

val data_date : (int * int * int) -> t

Build MySQL DATE (year, month, day) value

val data_time : (sign * int * int * int * Stdlib.Int64.t) -> t

Build MySQL TIME (sign, hour, min, sec, microsec) value

val data_datetime : ((int * int * int) * (int * int * int * Stdlib.Int64.t)) -> t

Build MySQL DATETIME ((year, month, day), (hour, min, sec, microsec)) value

val data_timestamp : ((int * int * int) * (int * int * int * Stdlib.Int64.t)) -> t

Build MySQL TIMESTAMP ((year, month, day), (hour, min, sec, microsec)) value

val data_float : float -> t

Build MySQL FLOAT value

val data_double : float -> t

Build MySQL DOUBLE value

val data_int24 : int -> t

Build MySQL MEDIUM INT value

val data_year : int -> t

Build MySQL YEAR value

val data_varchar : string -> t

Build MySQL VARCHAR value

val data_string : string -> t

Build MySQL CHAR value

val data_varstring : string -> t

Build MySQL VARCHAR value

val data_blob : Stdlib.Buffer.t -> t

Build MySQL BLOB value

val data_binary : Stdlib.Buffer.t -> t

Build MySQL BINARY value

val data_varbinary : Stdlib.Buffer.t -> t

Build MySQL VARBINARY value

val data_enum : string -> t

Build MySQL ENUM value

val data_set : string -> t

Build MySQL SET value

val data_bit : Bitstring.t -> t

Build MySQL BIT value

val data_geometry : Bitstring.t -> t

Build MySQL GEOMETRY value

val to_ocaml_int : t -> int option

Convert column data to OCaml value (int). NULL is converted into None.

  • raises Wrong_type

    if the column data is not of int type.

val to_ocaml_int64 : t -> Stdlib.Int64.t option

Convert column data to OCaml value (Int64). NULL is converted into None.

  • raises Wrong_type

    if the column data is not of Int64 type.

val to_ocaml_big_int : t -> Big_int.big_int option

Convert column data to OCaml value (Big_int). NULL is converted into None.

  • raises Wrong_type

    if the column data is not of Big_int type.

val to_ocaml_num : t -> Num.num option

Convert column data to OCaml value (Num). NULL is converted into None.

  • raises Wrong_type

    if the column data is not of Num type.

val to_ocaml_date : t -> (int * int * int) option

Convert column data to OCaml value (date). NULL is converted into None.

  • raises Wrong_type

    if the column data is not of date type.

val to_ocaml_time : t -> (sign * int * int * int * Stdlib.Int64.t) option

Convert column data to OCaml value (time). NULL is converted into None.

  • raises Wrong_type

    if the column data is not of time type.

val to_ocaml_dt_ts : t -> ((int * int * int) * (int * int * int * Stdlib.Int64.t)) option

Convert column data to OCaml value (datetime/timestamp). NULL is converted into None.

  • raises Wrong_type

    if the column data is not of datetime/timestamp type.

val to_ocaml_float : t -> float option

Convert column data to OCaml value (float). NULL is converted into None.

  • raises Wrong_type

    if the column data is not of float type.

val to_ocaml_string : t -> string option

Convert column data to OCaml value (string). NULL is converted into None.

  • raises Wrong_type

    if the column data is not of string type.

val to_ocaml_buffer : t -> Stdlib.Buffer.t option

Convert column data to OCaml value (Buffer). NULL is converted into None.

  • raises Wrong_type

    if the column data is not of Buffer type.

val to_ocaml_bitstring : t -> Bitstring.t option

Convert column data to OCaml value (Bitstring). NULL is converted into None.

  • raises Wrong_type

    if the column data is not of Bitstring type.

val eq : t -> t -> bool

eq v1 v2 tests for structural equality of v1 and v2

val type_to_string : t -> string

Convert column type to string

val to_string : t -> string option

Convert column data to string

OCaml

Innovation. Community. Security.