aboutsummaryrefslogtreecommitdiff
path: root/lib/file_handler/state.mli
blob: f744c3363d489187e8c27f8531e0c267f9d45352 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
type 'a t = {
  header : 'a option;
  transaction : bool;
  insert_stmt : Sqlite3.stmt option;
  check_key_stmt : Sqlite3.stmt option;
  row_number : int;
  sheet_number : int;
  delayed : 'a list;
}

type insert_result = {
  insert_stmt : Sqlite3.stmt option;
  check_key_stmt : Sqlite3.stmt option;
}

type ('a, 'b) mapper = {
  get_row : 'b -> 'a Array.t;
  get_value : 'a -> ImportCSV.DataType.t;
  default : 'a;
}

val insert_row :
  mapper:(_, 'row) mapper ->
  ImportAnalyser.Dependency.t ->
  _ ImportSQL.Db.t ->
  'row ->
  _ t ->
  (insert_result, ImportErrors.xlsError) result
(** Low level row insertion *)

val run_row :
  log_error:ImportErrors.t ->
  mapper:(_, 'row) mapper ->
  ImportAnalyser.Dependency.t ->
  _ ImportSQL.Db.t ->
  'row ->
  'a t ->
  'a t

val clear :
  log_error:ImportErrors.t ->
  'a ImportSQL.Db.t ->
  ImportAnalyser.Dependency.t ->
  ImportConf.Syntax.t ->
  unit ImportSQL.Db.result
(** Clean up the table after the insertion, check for the duplicates and external references *)