Mssqlex v2.0.0-beta.0 Mssqlex.ODBC View Source

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.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

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.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

commit(pid)

View Source
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

Link to this function

disconnect(pid)

View Source
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

Link to this function

query(pid, statement, params, opts)

View Source
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

Link to this function

rollback(pid)

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

Rolls back a transaction on the ODBC driver.

pid is the :odbc process id

Link to this function

start_link(conn_str, opts)

View Source
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.