Name

QBit::Application::Model::DB::clickhouse - Class for working with ClickHouse DB.

Description

Class for working with ClickHouse DB. It's not ORM.

GitHub

https://github.com/QBitFramework/QBit-Application-Model-DB-clickhouse

Install

  • cpanm QBit::Application::Model::DB::clickhouse

  • apt-get install libqbit-application-model-db-clickhouse-perl (http://perlhub.ru/)

Example:

__PACKAGE__->meta(
    tables => {
        stat => {
            fields => [
                {name => 'date', type => 'Date',},
                {name => 'hits', type => 'UInt32',},
            ],
            engine => {MergeTree => ['date', [',' => ['date', 'hits']], \8192]}
        },
    },
);

Package methods

filter

Arguments:

  • $filter - filter (perl variables)

  • %opts - additional options

    • type - type (AND/OR NOT)

Return values:

  • $filter - object (QBit::Application::Model::DB::Filter)

Example:

my $filter = $app->clickhouse->filter([id => '=' => \23]);

query

Arguments:

  • %hash - options

    • without_table_alias - boolean(default: false)

Return values:

  • $query - object (QBit::Application::Model::DB::clickhouse::Query)

Example:

my $table = $app->clickhouse->stat;

my $query = $app->clickhouse->query();
$query->_field_to_sql(undef, 'hits', $table); # `stat`.`hits`

my $query2 = $app->clickhouse->query(without_table_alias => TRUE);
$query->_field_to_sql(undef, 'hits', $table); # `hits`

Internal packages

QBit::Application::Model::DB::clickhouse::Field - class for ClickHouse fields;
QBit::Application::Model::DB::clickhouse::Query - class for ClickHouse queries;
QBit::Application::Model::DB::clickhouse::Table - class for ClickHouse tables;
QBit::Application::Model::DB::clickhouse::dbi - class for ClickHouse DBI;
QBit::Application::Model::DB::clickhouse::st - class for ClickHouse sth;