Connection.Odbc (etl_core v0.1.55)
Module for working with the ODBC library. It frees you from having to know how Erlang's :odbc library works.
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.
Functions
connect(data_source)
Establishes the connection to Data Source
Parameter:
- data_source: List. Data source information.
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.
delete(pid, statement)
Delete rows from the specified table
Parameters:
- pid: Process. Process connecting Elixir and ODBC.
- statement: String. SQL Statement.
Return:
- Exception | {:updated, n} where n is the number of records deleted
get_uuid(pid)
Genera un UUID
Parameter:
- pid: Process.
Return:
- string | Exception. If the query succeeds, it returns the UUID; otherwise, it raises an exception from `:odbc.sql_query/2` statement.
insert(pid, statement)
Inserts an object into the specified table
Parameters:
- pid: Process. Process connecting Elixir and ODBC.
- statement: String. SQL Statement.
Return:
- {:inserted, 1} | Exception
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()
Start the ODBC application
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()
Stop the ODBC application
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.
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:
- pid: Process. Process connecting Elixir and ODBC.
- statement: String. SQL Statement.
Return:
- Exception | {:updated, n} where n is the number of records updated