Connection.Odbc (etl_core v0.1.54)

Module for working with the ODBC library. It frees you from having to know how Erlang's :odbc library works.

Link to this section Summary

Functions

Establishes the connection to Data Source

Delete rows from the specified table

Genera un UUID

Inserts an object into the specified table

Create and execute an SQL statement of type `SELECT xx FROM x WHERE xxx. It is assumed that WHERE condition will only have the AND operator. Para ### Parameters: - pid: Process. Process connecting Elixir and ODBC. - statement: String. SQL Statement. ### Return: - list of (list of tuples ({:atom, :string})) | Exception. Fields with null values are ignored.

Start the ODBC application

Stop the ODBC application

Update an object into the specified table. It uses the retry decorator to retry the execution of the statement, in case of a concurrency error issued by BigQuery.

Link to this section Functions

Link to this function

connect(data_source)

Establishes the connection to Data Source

parameter

Parameter:

- data_source: List. Data source information.

return

Return:

- PID | Exception. If the connection can be established with the parameters defined in the configuration files, process identifier is returned. Otherwise, it throws an exception with the error.
Link to this function

delete(pid, statement)

Delete rows from the specified table

parameters

Parameters:

- pid: Process. Process connecting Elixir and ODBC.

- statement: String. SQL Statement.

return

Return:

- Exception | {:updated, n} where n is the number of records deleted

Genera un UUID

parameter

Parameter:

- pid: Process.

return

Return:

- string | Exception. If the query succeeds, it returns the UUID; otherwise, it raises an exception from `:odbc.sql_query/2` statement.
Link to this function

insert(pid, statement)

Inserts an object into the specified table

parameters

Parameters:

- pid: Process. Process connecting Elixir and ODBC.

- statement: String. SQL Statement.

return

Return:

- {:inserted, 1} | Exception
Link to this function

select(pid, statement)

Create and execute an SQL statement of type `SELECT xx FROM x WHERE xxx. It is assumed that WHERE condition will only have the AND operator. Para ### Parameters: - pid: Process. Process connecting Elixir and ODBC. - statement: String. SQL Statement. ### Return: - list of (list of tuples ({:atom, :string})) | Exception. Fields with null values are ignored.

Start the ODBC application

return

Return:

- :ok | exception. If the ODBC application has not been started or if it has already been started, return the atom. Otherwise, it throws an exception with the error.

Stop the ODBC application

return

Return:

- :ok | exception. If the ODBC application has not been stopped or if it has already been stopped, return the atom. Otherwise, it throws an exception with the error.
Link to this function

update(pid, statement)

Update an object into the specified table. It uses the retry decorator to retry the execution of the statement, in case of a concurrency error issued by BigQuery.

parameters

Parameters:

- pid: Process. Process connecting Elixir and ODBC.

- statement: String. SQL Statement.

return

Return:

- Exception | {:updated, n} where n is the number of records updated