Skip to content

Elixir lib to work with ClickHouse database

License

Notifications You must be signed in to change notification settings

ally9335/clickhousex

This branch is 6 commits behind plausible/clickhousex:master.

Folders and files

NameName
Last commit message
Last commit date
Sep 20, 2018
Oct 8, 2021
Feb 20, 2020
Oct 5, 2022
Oct 8, 2021
Feb 20, 2020
Feb 20, 2020
Mar 23, 2018
Mar 23, 2018
Jun 5, 2019
Apr 28, 2022
Apr 28, 2022

Repository files navigation

Clickhousex

ClickHouse database driver to connect with Elixir application by HTTP interface.

Installation

If available in Hex, the package can be installed by adding clickhousex to your list of dependencies in mix.exs:

def deps do
  [
    {:clickhousex, "~> 0.4.0"}
  ]
end

Start driver

Call start_link()/1 function and pass connection options:

Clickhousex.start_link([scheme: :http, hostname: "localhost", port: 8123, database: "default", username: "user", password: "654321"])

Options expects a keyword list with zero or more of:

  * `scheme` - Scheme (:http | :https). Default value: :http
  * `hostname` - The server hostname. Default value: "localhost"
  * `database` - Database name. Default value: "default"
  * `port` - The server port number. Default value: 8123
  * `username` - Username. Default value: nil
  * `password` - User's password. Default value: nil

Queries examples

iex(1)> {:ok, pid} = Clickhousex.start_link([scheme: :http, hostname: "localhost", port: 8123, database: "system"])
{:ok, #PID<0.195.0>}
iex(2)> Clickhousex.query(pid, "SHOW TABLES", [])
{:ok, %Clickhousex.Query{columns: nil, name: "", statement: "SHOW TABLES"},
 %Clickhousex.Result{columns: ["name"], command: :selected, num_rows: 23,
  rows: [["asynchronous_metrics"], ["build_options"], ["clusters"], ["columns"],
   ["databases"], ["dictionaries"], ["events"], ["functions"],
   ["graphite_retentions"], ["merges"], ["metrics"], ["models"], ["numbers"],
   ["numbers_mt"], ["one"], ["parts"], ["parts_columns"], ["processes"],
   ["replicas"], ["replication_queue"], ["settings"], ["tables"],
   ["zookeeper"]]}}
iex(3)>

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/clickhousex.

About

Elixir lib to work with ClickHouse database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Elixir 100.0%