Tds v2.1.1 Tds View Source

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

Link to this type

execute_option()

View Source
execute_option() ::
  {:decode_mapper, (list() -> term())} | {:resultset, boolean()} | option()
Link to this type

isolation_level()

View Source
isolation_level() ::
  :read_uncommitted
  | :read_committed
  | :repeatable_read
  | :serializable
  | :snapshot
  | :no_change
Link to this type

resultset()

View Source
resultset() :: [Tds.Result.t()]
Link to this type

start_option()

View Source
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()
Link to this type

transaction_option()

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

Link to this section Functions

Link to this function

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

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

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

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

Link to this function

encode_uuid(value)

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

Encodes uuid string into MS uniqueidentifier binary

Link to this function

encode_uuid!(value)

View Source
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
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
execute!(conn(), Tds.Query.t(), list(), [execute_option()]) :: Tds.Result.t()
Link to this function

generate_uuid()

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

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

Link to this function

json_library()

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

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

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

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

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

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

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

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

View Source
query_multi(conn(), iodata(), option(), [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.

Link to this function

rollback(conn, any)

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

See DBConnection.rollback/2.

Link to this function

start_link(opts \\ [])

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

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

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