2017 © Pedro Peláez
 

yii2-extension clickhouse

Driver yii2 for column-oriented database ClickHouse.

image

bashkarev/clickhouse

Driver yii2 for column-oriented database ClickHouse.

  • Friday, December 8, 2017
  • by bashkarev
  • Repository
  • 2 Watchers
  • 5 Stars
  • 57 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 1 Open issues
  • 4 Versions
  • 8 % Grown

The README.md

Extension ClickHouse for Yii 2

This extension provides the ClickHouse integration for the Yii framework 2.0. Main features: - SQL commands - Query builder - Schema builder - Migrations - Batch Insert - Parallel insert from large CSV files - Valid handling of UInt64 type in PHP - Supports Decimals and Nullable fields, (*1)

Build Status, (*2)

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

composer require bashkarev/clickhouse

Configuration

To use this extension, simply add the following code in your application configuration:, (*5)

return [
    //....
    'clickhouse' => [
        'class' => 'bashkarev\clickhouse\Connection',
        'dsn' => 'host=localhost;port=8123;database=default;connect_timeout_with_failover_ms=10',
        'username' => 'default',
        'password' => '',
    ],
];

All settings, (*6)

Using DebugPanel

Add the following to you application config to enable it (if you already have the debug module enabled, it is sufficient to just add the panels configuration):, (*7)

    // ...
    'bootstrap' => ['debug'],
    'modules' => [
        'debug' => [
            'class' => 'yii\\debug\\Module',
            'panels' => [
                'clickhouse' => [
                    'class' => 'bashkarev\clickhouse\debug\Panel',
                    // 'db' => 'clickhouse', // ClickHouse component ID, defaults to `db`. Uncomment and change this line, if you registered component with a different ID.
                ],
            ],
        ],
    ],
    // ...

Using Migrations

In order to enable this command you should adjust the configuration of your console application:, (*8)

return [
    // ...
    'controllerMap' => [
        'clickhouse-migrate' => 'bashkarev\clickhouse\console\controllers\MigrateController'
    ],
];
# creates a new migration named 'create_target'
yii clickhouse-migrate/create create_target

# applies ALL new migrations
yii clickhouse-migrate

# reverts the last applied migration
yii clickhouse-migrate/down

Access to native SMI2 ClickHouse client

$client = \Yii::$app->clickhouse->getClient();

Insert csv files

Files are uploaded in parallel., (*9)

$db = \Yii::$app->clickhouse;
$client = $db->getClient();

$results = $client->insertBatchFiles('table_name', ['file_with_data.csv']);

$state = $results['file_with_data.csv'];
$isSuccess = !$state->isError();
$uploadInfo = $state->responseInfo();

print_r($uploadInfo);

The Versions

08/12 2017

dev-master

9999999-dev

Driver yii2 for column-oriented database ClickHouse.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar bashkarev

yii2 clickhouse

08/12 2017

1.1.0

1.1.0.0

Driver yii2 for column-oriented database ClickHouse.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar bashkarev

yii2 clickhouse

28/08 2017

1.0.1

1.0.1.0

Driver yii2 for column-oriented database ClickHouse.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar bashkarev

yii2 clickhouse

17/06 2017

1.0.0

1.0.0.0

Driver yii2 for column-oriented database ClickHouse.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar bashkarev

yii2 clickhouse