View Source SnowflakeEx (snowflake_elixir v0.2.0)
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
Functions
Executes a prepared query.
Executes a prepared query.
Runs an (extended) query and returns the result or raises SnowflakeEx.Error if
there was an error. See query/3.
Link to this section Types
@type 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.
@type option() :: {:mode, :transaction} | DBConnection.option()
@type 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
@spec 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.
@spec execute(conn(), SnowflakeEx.Query.t(), list(), [option()]) :: {:ok, SnowflakeEx.Query.t(), SnowflakeEx.Result.t()} | {:error, Exception.t()}
Executes a prepared query.
options
Options
Options are passed to DBConnection.execute/4, see it's documentation for
all available options.
examples
Examples
iex> {:ok, query} = SnowflakeEx.prepare(conn, "", "SELECT ? * ?")
iex> {:ok, %SnowflakeEx.Result{rows: [row]}} = SnowflakeEx.execute(conn, query, [2, 3])
iex> row
[6]
@spec query!(conn(), iodata(), list(), [execute_option()]) :: SnowflakeEx.Result.t()
Runs an (extended) query and returns the result or raises SnowflakeEx.Error if
there was an error. See query/3.