View Source Tds (Tds v2.3.5)

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.

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.

Types

@type conn() :: DBConnection.conn()
@type execute_option() ::
  {:decode_mapper, (list() -> term())} | {:resultset, boolean()} | option()
@type isolation_level() ::
  :read_uncommitted
  | :read_committed
  | :repeatable_read
  | :serializable
  | :snapshot
  | :no_change
@type option() :: DBConnection.option()
@type resultset() :: [Tds.Result.t()]
@type start_option() ::
  {:hostname, String.t()}
  | {:port, :inet.port_number()}
  | {:database, String.t()}
  | {:username, String.t()}
  | {:password, String.t()}
  | {:timeout, timeout()}
  | {:connect_timeout, timeout()}
  | {:execution_mode, :prepare_execute | :executesql}
  | DBConnection.start_option()
@type transaction_option() ::
  {:mode, :transaction | :savepoint}
  | {:isolation_level, isolation_level()}
  | option()

Functions

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

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

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

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

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

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

Encodes UUID string into MS uniqueidentifier binary.

@spec 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
@spec 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
@spec execute!(conn(), Tds.Query.t(), list(), [execute_option()]) :: Tds.Result.t()
@spec generate_uuid() :: <<_::128>>

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

@spec 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
@spec prepare(conn(), iodata(), [option()]) ::
  {:ok, Tds.Query.t()} | {:error, Exception.t()}
Link to this function

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

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

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

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

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

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

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

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

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

See DBConnection.rollback/2.

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

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

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