Skip to content
This repository has been archived by the owner on Apr 13, 2024. It is now read-only.

joshuataylor/snowflake_elixir_ecto

Repository files navigation

SnowflakeExEcto

hex.pm hexdocs.pm hex.pm hex.pm github.com

WIP, NOT PRODUCTION READY YET

Integrates Snowflake through snowflake_elixir driver with ecto_sql, which allows you to use your schemas with Snowflake!

Installation

Add snowflake_elixir_ecto to your list of dependencies in mix.exs:

def deps do
  [
    {:snowflake_elixir_ecto, "~> 0.1.0"}
  ]
end

Configuration

In your config/config.exs file, add the following:

config :my_app, MyApp.Repo,
  username: "yourusername",
  password: "supersecret",
  host: "https://xxx.your-region.snowflakecomputing.com",
  account_name: "lol1234",
  database: "SNOWFLAKE_TEST_DRIVER",
  schema: "PUBLIC",
  role: "ENGINEER",
  pool_size: 1,
  warehouse: "COMPUTE_WH"

Then in your repo.ex:

defmodule MyApp.Repo do
  use Ecto.Repo,
    otp_app: :my_app,
    adapter: Ecto.Adapters.Snowflake
end

Connection options

* `:host` - Server hostname, including https. Example: "https://xxx.us-east-1.snowflakecomputing.com"
* `:username` - Username for your account.
* `:password` - Password for your account.
* `:warehouse` - Warehouse to use on Snowflake. If none set, will use default for the account.
* `:account_name` - Account name. This is usually the name between the https:// and us-east-1 (or whatever region).
* `:database` - the database to connect to.
* `:schema` - the schema to connect to.
* `:async` - If set to true, will issue a query then connect every `:async_interval` to see if the query has completed.

Data Mapping

WIP, TODO

Snowflake Differences compared to a "traditional" RDBMS

Snowflake isn't like Postgres/MySQL or another database you might be use to. There are a few gotchas you need to watch out for.

Before using this library, it's recommended that you learn how Snowflake works at a basic level.

Indexing

  • Snowflake does not support indexes, at all.
  • Snowflake does not support unique indexes. You can create them, but it's not enforced. See contraints

Inserts

  • Snowflake does not support RETURNING. Thoughts around how to handle this are here
  • Snowflake does not have UPSERT support.

Data binding

  • Snowflake must insert integers as strings in the JSON for binding, so it's encoded as "0", otherwise you'll get compilation error:\nUnsupported data type 'java.lang.Integer'

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages