Snowflex.Connection behaviour (Snowflex v0.2.1)

Defines a Snowflake connection.

Definition

When used, the connection expects the :otp_app option. You may also define a standard timeout. This will default to 60 seconds.

defmodule SnowflakeConnection do
  use Snowflex.Connection,
    otp_app: :my_app,
    timeout: :timer.seconds(60)
end

Configuration should be extended in your config files.

# config/prod.exs
config :my_app, SnowflakeConnection,
  size: [
    max: 10,
    min: 5
  ],
  connection: [
      server: "snowflex.us-east-8.snowflakecomputing.com",
      role: "DEV",
      warehouse: "CUSTOMER_DEV_WH"
    ]

The connection will default to using the Snowflex.Worker module. You are able to define a diferent one for testing/development purposes in your configurations as well.

# config/dev.exs
  config :my_app, SnowflakeConnection,
    size: [
      max: 1,
      min: 1
    ],
    worker: MyApp.MockWorker

Usage

Ensure the connection is started as part of your application.

defmodule MyApp.Application do

  def start(_, _) do
    ...

    children = [
      ...,
      SnowflakeConnection
    ]
  end
end

execute/1

query = "SELECT * FROM foo"

SnowflakeConnection.execute(query)

execute/2

query = """
  SELECT * FROM foo
  WHERE bar = ?
"""

SnowflakeConnection.execute(query, [Snowflex.string_param("baz")])

Link to this section Summary

Callbacks

Wraps Snowflex.sql_query/3 and injects the relevant information from the connection

Wraps Snowflex.param_query/4 and injects the relevant information from the connection

Link to this section Callbacks

Specs

execute(query :: String.t()) :: Snowflex.sql_data() | {:error, any()}

Wraps Snowflex.sql_query/3 and injects the relevant information from the connection

Link to this callback

execute(query, params)

Specs

execute(query :: String.t(), params :: [Snowflex.query_param()]) ::
  Snowflex.sql_data() | {:error, any()}

Wraps Snowflex.param_query/4 and injects the relevant information from the connection