Ecto ClickHouse Adapter
Ecto Adapter for ClickHouse using :ch
Caveats and limitations
See :ch
Installation
defp deps do
[
{:chto, "~> 0.1.0"}
]
endUsage
Define your repo similar to this.
defmodule MyApp.Repo do
use Ecto.Repo, otp_app: :my_app, adapter: Ecto.Adapters.ClickHouse
end
Configure your repository similar to the following. If you want to know more
about the possible options to pass the repository, checkout the documentation
for Ecto.Adapters.ClickHouse. It will have
more information on what is configurable.
config :my_app,
ecto_repos: [MyApp.Repo]
config :my_app, MyApp.Repo,
url: "http://localhost:8123/default"
Ecto schemas need to use custom Ecto types when there is any ambiguity.
See Ecto types section in the documentation for the list of available types.
defmodule Example do
use Ecto.Schema
@primary_key false
schema "example" do
field :a, Ch.Types.UInt32
field :b, :string
field :c, :naive_datetime
end
end
For schemaless inserts, a :types keyword list can be provided.
Repo.insert_all("example", [%{a: 1, b: "2"}, %{a: 3, c: nil}], types: [a: :u32, b: :string, c: :datetime])For deletes, custom settings can be provided.
Repo.delete_all("example", settings: [allow_experimental_lightweight_delete: 1, mutations_sync: 1])