View Source Tds (Tds v2.3.1)

Microsoft SQL Server driver for Elixir.

Tds is partial implementation of the Micorosoft SQL Server MS-TDS Tabular Data Stream Protocol.

A Tds query is performed in separate server-side prepare and execute stages.

At the moment query handle is not reused, but there is plan to cahce handles in near feature. It uses RPC requests by default to Sp_Prepare (ProcId=11) and Sp_Execute (ProcId=12) query, but it is possible to configure driver to use only Sp_ExecuteSql.

Please consult with configuration how to do this.

Link to this section Summary

Functions

Decodes MS uniqueidentifier binary to its string representation.

Same as decode_uuid/1 but raises ArgumentError if value is invalid.

Encodes UUID string into MS uniqueidentifier binary.

Same as encode_uuid/1 but raises ArgumentError if value is invalid.

Generates a version 4 (random) UUID in the MS uniqueidentifier binary format.

Returns the configured JSON library.

Executes statement that can contain multiple SQL batches, result will contain all results that server yield for each batch.

Link to this section Types

Specs

conn() :: DBConnection.conn()

Specs

execute_option() ::
  {:decode_mapper, (list() -> term())} | {:resultset, boolean()} | option()

Specs

isolation_level() ::
  :read_uncommitted
  | :read_committed
  | :repeatable_read
  | :serializable
  | :snapshot
  | :no_change

Specs

option() :: DBConnection.option()

Specs

resultset() :: [Tds.Result.t()]

Specs

start_option() ::
  {:hostname, String.t()}
  | {:port, :inet.port_number()}
  | {:database, String.t()}
  | {:username, String.t()}
  | {:password, String.t()}
  | {:timeout, timeout()}
  | {:connect_timeout, timeout()}
  | DBConnection.start_option()

Specs

transaction_option() ::
  {:mode, :transaction | :savepoint}
  | {:isolation_level, isolation_level()}
  | option()

Link to this section Functions

Specs

child_spec([start_option()]) :: Supervisor.Spec.spec()
Link to this function

close(conn, query, opts \\ [])

View Source

Specs

close(conn(), Tds.Query.t(), [option()]) :: :ok | {:error, Exception.t()}
Link to this function

close!(conn, query, opts \\ [])

View Source

Specs

close!(conn(), Tds.Query.t(), [option()]) :: :ok

Decodes MS uniqueidentifier binary to its string representation.

Same as decode_uuid/1 but raises ArgumentError if value is invalid.

Specs

encode_uuid(any()) :: :error | {:ok, <<_::128>>}

Encodes UUID string into MS uniqueidentifier binary.

Specs

encode_uuid!(any()) :: <<_::128>>

Same as encode_uuid/1 but raises ArgumentError if value is invalid.

Link to this function

execute(conn, query, params, opts \\ [])

View Source

Specs

execute(conn(), Tds.Query.t(), list(), [execute_option()]) ::
  {:ok, Tds.Query.t(), Tds.Result.t()} | {:error, Tds.Error.t()}
Link to this function

execute!(conn, query, params, opts \\ [])

View Source

Specs

execute!(conn(), Tds.Query.t(), list(), [execute_option()]) :: Tds.Result.t()

Specs

generate_uuid() :: <<_::128>>

Generates a version 4 (random) UUID in the MS uniqueidentifier binary format.

Specs

json_library() :: module()

Returns the configured JSON library.

To customize the JSON library, include the following in your config/config.exs:

config :tds, json_library: SomeJSONModule

Defaults to Jason.

Link to this function

prepare(conn, statement, opts \\ [])

View Source

Specs

prepare(conn(), iodata(), [option()]) ::
  {:ok, Tds.Query.t()} | {:error, Exception.t()}
Link to this function

prepare!(conn, statement, opts \\ [])

View Source

Specs

prepare!(conn(), iodata(), [option()]) :: Tds.Query.t() | no_return()
Link to this function

query(conn, statement, params, opts \\ [])

View Source

Specs

query(conn(), iodata(), list(), [execute_option()]) ::
  {:ok, Tds.Result.t()} | {:error, Exception.t()}
Link to this function

query!(conn, statement, params, opts \\ [])

View Source

Specs

query!(conn(), iodata(), list(), [execute_option()]) ::
  Tds.Result.t() | no_return()
Link to this function

query_multi(conn, statemnt, params, opts \\ [])

View Source

Specs

query_multi(conn(), iodata(), list(), [execute_option()]) ::
  {:ok, resultset()} | {:error, Exception.t()}

Executes statement that can contain multiple SQL batches, result will contain all results that server yield for each batch.

Specs

rollback(DBConnection.t(), reason :: any()) :: no_return()

See DBConnection.rollback/2.

Specs

start_link([start_option()]) :: {:ok, conn()} | {:error, Tds.Error.t() | term()}
Link to this function

transaction(conn, fun, opts \\ [])

View Source

Specs

transaction(conn(), (DBConnection.t() -> result), [transaction_option()]) ::
  {:ok, result} | {:error, any()}
when result: var