Git Product home page Git Product logo

clickhouse-rails's Introduction

Clickhouse rails

Build Status codecov

Install

  1. Add to Gemfile
gem 'clickhouse-rails'
  1. Run bundle
$ bundle install
  1. Init config files and folders
$ rails g clickhouse:install
  1. Change clickhouse.yml at config/clickhouse.yml path

Usage

  1. Create migrations
$ rails g clickhouse:migration add_tmp_table
      create  db/clickhouse/migrate/002_add_tmp_table.rb
  1. Edit file like this:
# db/clickhouse/migrate/002_add_tmp_table.rb
class AddTmpTable < Clickhouse::Rails::Migrations::Base
  def self.up
    create_table :tmp do |t|
      t.date   :date
      t.uint16 :id

      t.engine "MergeTree(date, (date), 8192)"
    end
  end
end
  1. Run migrations
$ rake clickhouse:db:migrate

You can create class of clickhouse table:

# app/models/custom_table.rb
class CustomTable
  include Clickhouse::Table
end

And insert rows like this:

CustomTable.insert_rows([{a:1, b:2}])
CustomTable.insert_row({a:1, b:2})

Alter table migration

  alter_table "analytics_table" do
    fetch_column :new_ids, :uint8 # Adds column new_ids or skip it
  end

TODO:

  1. Rollback migrations
  2. Alter table

Additional clickhouse links

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.