Module Etl.Helpers

val (let*) : 'a Lwt.t -> ('a -> 'b Lwt.t) -> 'b Lwt.t
val read_file : string -> string

Reads the entire contents of a file into a string.

  • parameter filename

    Path to the file to read

  • returns

    String containing the full contents of the file

val write_file : string -> Types.result list -> unit

Writes results to a CSV file.

  • parameter filename

    Path to the output CSV file

  • parameter results

    List of result records to write

val http_get : string -> (string, string) Stdlib.result Lwt.t

Performs an HTTP GET request.

  • parameter url

    URL to fetch

  • returns

    Lwt promise containing result or error message

val http_get_string : string -> string

Runs HTTP GET and handles result. Wrapper on the http_get function.

  • parameter url

    URL to fetch

  • returns

    String containing response body or exits on failure

val create_table : Sqlite3.db -> unit

Creates results table in SQLite database.

  • parameter db

    SQLite database handle

val create_ym_table : Sqlite3.db -> unit

Creates year month table in SQLite database.

  • parameter db

    SQLite database handle

val insert_result : Sqlite3.db -> Types.result -> unit

Inserts a result into SQLite database.

  • parameter db

    SQLite database handle

  • parameter result

    Record to insert

val insert_ym_result : Sqlite3.db -> Types.ym_result -> unit

Inserts a year-month result into SQLite database.

  • parameter db

    SQLite database handle

  • parameter result

    Year-month record to insert

val create_db : string -> Sqlite3.db

Creates and initializes a SQLite database with required tables.

  • parameter filename

    Path to the SQLite database file

  • returns

    Database handle for further operations

val write_to_sqlite : Sqlite3.db -> Types.result list -> Types.ym_result list -> unit

Writes results and year-month results to an SQLite database.

  • parameter db

    SQLite database handle

  • parameter results

    List of result records to insert

  • parameter ym_results

    List of year-month result records to insert

val parse_user_input : unit -> Types.user_input

Parses user input to create filter criteria for origin and status. Prompts the user to enter numeric choices for origin and status filters, converting them into string representations.

  • returns

    Record containing origin_filter and status_filter strings