View Source Csv2sql.Database behaviour (Csv2sql v0.1.0)

Database specific functions

Summary

Types

@type csv_col_types_list() :: [{String.t(), String.t()}]
@type db_result_types() :: MyXQL.Result.t() | Postgrex.Result.t()
@type file_status() :: :pending | :analyze | :loading | :done | :failure
@type files_map() :: %{required(String.t()) => File.t()}
Link to this type

supported_db_data_types()

View Source
@type supported_db_data_types() ::
  String.t() | number() | boolean() | Date.t() | DateTime.t() | nil
@type type_map() :: %{
  is_empty: boolean(),
  is_date: boolean(),
  is_datetime: boolean(),
  is_boolean: boolean(),
  is_integer: boolean(),
  is_float: boolean(),
  is_text: boolean(),
  max_data_length: non_neg_integer()
}

Callbacks

@callback db_name() :: String.t()
@callback delimiter() :: <<_::8>>
@callback encode(String.t(), String.t()) :: supported_db_data_types()
Link to this callback

get_ordering_column_type()

View Source
@callback get_ordering_column_type() :: String.t()
@callback type_mapping(type_map()) :: String.t()

Functions

Link to this function

get_create_table_ddl(file_path, db_name, column_types)

View Source
@spec get_create_table_ddl(String.t(), String.t(), csv_col_types_list()) :: String.t()
@spec get_db_name() :: String.t()
Link to this function

get_db_row_count_if_exists(file_path)

View Source
@spec get_db_type(type_map()) :: String.t()
Link to this function

get_drop_table_ddl(file_path, db_name)

View Source
@spec get_drop_table_ddl(String.t(), String.t()) :: String.t()
@spec get_repo(:mysql | :postgres | String.t()) ::
  Csv2sql.MySQLRepo | Csv2sql.PostgresRepo
Link to this function

get_table_name(file_path)

View Source
Link to this function

insert_data_chunk(file, data_chunk)

View Source
@spec insert_data_chunk(Csv2sql.File.t(), list()) :: :ok
@spec run_query!(String.t()) :: db_result_types()
@spec run_query!(atom(), String.t()) :: db_result_types()
Link to this function

string_column_type(max_data_length)

View Source
@spec varchar_limit() :: pos_integer()