View Source Snowpack.ODBC (Snowpack v0.7.5)

Adapter to Erlang's :odbc module.

This module is a GenServer that handles communication between Elixir and Erlang's :odbc module.

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

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Disconnects from the ODBC driver.

Callback implementation for GenServer.init/1.

Sends a parametrized query to 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

describe_result(pid, query_id)

View Source
@spec describe_result(pid(), iodata()) ::
  {:selected, [binary()], [tuple()]} | {:error, Snowpack.Error.t()}
@spec disconnect(pid()) :: :ok

Disconnects from the ODBC driver.

pid is the :odbc process id

@spec init(keyword()) :: {:ok, any()}

Callback implementation for GenServer.init/1.

Link to this function

query(pid, statement, params, opts, with_query_id \\ false)

View Source
@spec query(pid(), iodata(), Keyword.t(), Keyword.t(), boolean()) ::
  {:selected, [binary()], [tuple()]}
  | {:selected, [binary()], [tuple()], [{binary()}]}
  | {:updated, non_neg_integer()}
  | {:error, Snowpack.Error.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
    • timeout in millisecods (defaults to 2 minutes)
  • with_query_id runs query in transaction and selects LAST_QUERY_ID()
@spec start_link(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.