Mssqlex v1.0.0 Mssqlex.ODBC

Adapter to Erlang’s :odbc module.

This module is a GenServer that handles communication between Elixir and Erlang’s :odbc module. Transformations are kept to a minimum, primarily just translating binaries to charlists and vice versa.

It is used by Mssqlex.Protocol and should not generally be accessed directly.

Summary

Functions

Commits a transaction on the ODBC driver

Disconnects from the ODBC driver

Sends a parametrized query to the ODBC driver

Rolls back a transaction on the ODBC driver

Starts the connection process to the ODBC driver

Functions

commit(pid)
commit(pid) :: :ok | {:error, Exception.t}

Commits a transaction on the ODBC driver.

Note that unless in autocommit mode, all queries are wrapped in implicit transactions and must be committed.

pid is the :odbc process id

disconnect(pid)
disconnect(pid) :: :ok

Disconnects from the ODBC driver.

Attempts to roll back any pending transactions. If a pending transaction cannot be rolled back the disconnect still happens without any changes being committed.

pid is the :odbc process id

query(pid, statement, params, opts)
query(pid, iodata, Keyword.t, Keyword.t) ::
  {:selected, [binary], [tuple] | {:updated, non_neg_integer}} |
  {:error, Exception.t}

Sends a parametrized query to the ODBC driver.

Interface to :odbc.param_query/3.See Erlang’s ODBC guide for usage details and examples.

pid is the :odbc process id statement is the SQL query string params are the parameters to send with the SQL query opts are options to be passed on to :odbc

rollback(pid)
rollback(pid) :: :ok | {:error, Exception.t}

Rolls back a transaction on the ODBC driver.

pid is the :odbc process id

start_link(conn_str, opts)
start_link(binary, Keyword.t) :: {:ok, pid}

Starts the connection process to the ODBC driver.

conn_str should be a connection string in the format required by your ODBC driver. opts will be passed verbatim to :odbc.connect/2.