SnowflakeEx (snowflake_elixir v0.1.0) View Source

Snowflake driver for Elixir.

It uses the Snowflake REST API to communicate with Snowflake, with an earlier version set for JSON. There isn't an Elixir Arrow library (yet!), so it seems that setting an earlier Java version seems to give us back JSON results.

Right now the library doesn't support MFA, so you'll need to either use private key auth (https://docs.snowflake.com/en/user-guide/odbc-parameters.html#using-key-pair-authentication) or connecting using a username & password. A private key auth is highly recommended as you can rotate passwords easier. MFA with Snowflake is a mess.

This module handles the connection to Snowflake, providing support for queries, transactions, connection backoff, logging,

A Genserver logs into Snowflake for you, then uses this session for all other interactions (queries, etc) and ensuring we don't overload the Snowflake server with requests. If you issue too many requests to Snowflake, your query might be queued.

Link to this section Summary

Types

A connection process name, pid or reference.

Link to this section Types

Specs

conn() :: DBConnection.conn()

A connection process name, pid or reference.

A connection reference is used when making multiple requests to the same connection, see transaction/3.

Specs

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

Specs

option() :: {:mode, :transaction} | DBConnection.option()

Specs

start_option() ::
  {:host, String.t()}
  | {:database, String.t()}
  | {:username, String.t()}
  | {:password, String.t()}
  | {:warehouse, String.t()}
  | {:parameters, keyword()}
  | {:schema, String.t()}
  | {:account_name, String.t()}
  | {:timeout, timeout()}
  | {:connect_timeout, timeout()}
  | {:prepare, :named | :unnamed}
  | {:transactions, :strict | :naive}
  | {:types, module()}
  | {:disconnect_on_error_codes, [atom()]}
  | DBConnection.start_option()

Link to this section Functions

Link to this function

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

View Source

Specs

execute(conn(), SnowflakeEx.Query.t(), list(), [option()]) ::
  {:ok, SnowflakeEx.Query.t(), SnowflakeEx.Result.t()} | {:error, Exception.t()}

Executes a prepared query.

Options

Options are passed to DBConnection.execute/4, see it's documentation for all available options.

Examples

iex> {:ok, query} = SnowflakeEx.prepare(conn, "", "SELECT ? * ?")
iex> {:ok, %SnowflakeEx.Result{rows: [row]}} = SnowflakeEx.execute(conn, query, [2, 3])
iex> row
[6]
Link to this function

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

View Source

Specs

execute!(conn(), SnowflakeEx.Query.t(), list(), keyword()) ::
  SnowflakeEx.Result.t()

Executes a prepared query.

Returns %SnowflakeEx.Result{} on success, or raises an exception if there was an error.

See: execute/4.

Link to this function

prepare_execute(conn, name, statement, params, opts \\ [])

View Source
Link to this function

prepare_execute!(conn, name, statement, params, opts \\ [])

View Source
Link to this function

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

View Source