You can install the package via composer:
composer require prageeth-peiris/laravel-query-builder-to-clickhouse
// Usage description here
//Add following database connections to config/database.php
'bavix::clickhouse' => [
'driver' => 'bavix::clickhouse',
'host' => env('CLICKHOUSE_HOST'),
'port' => env('CLICKHOUSE_PORT',8123),
'database' => env('CLICKHOUSE_DATABASE'),
'username' => env('CLICKHOUSE_USER','default'),
'password' => env('CLICKHOUSE_PASSWORD'),
'options' => [
'timeout' => 20,
'protocol' => 'http'
]
],
'clickhouse_custom' => [
'driver' => 'bavix::clickhouse::custom',
'host' => env('CLICKHOUSE_HOST'),
'port' => env('CLICKHOUSE_PORT',8123),
'database' => env('CLICKHOUSE_DATABASE'),
'username' => env('CLICKHOUSE_USER','default'),
'password' => env('CLICKHOUSE_PASSWORD'),
'options' => [
'timeout' => 20,
'protocol' => 'http'
]
]
//extend from this model and start using clickhouse
use PrageethPeiris\LaravelQueryBuilderToClickhouse\Model;
Class CustomModel extends BaseClickHouseModel {
//this is required if you are doing sub query joining
protected $tableJoinKey = 'page';
}
//use table with a suffix at runtime
CustomModel::useTableSuffix("in_memory")->insert($data)
//here comes a method to do sub query joining very easily
CustomModel::autoLeftJoinSubQuery(CustomModel::class,OtherModel::GroupBySomething())
->autoLeftJoinSubQuery(CustomModel::class,OtherModel::GroupBySomethingAndSomething())
This is an opinionated package so this cache results by raw clickhosue sql query. It will use your default cache driver. to clear cache run
php artisan cache:clear
- PHP 8
- Laravel 8
- https://github.com/bavix/laravel-clickhouse
- https://github.com/MariosTheof/laravel-clickhouse-migrations
Read related packages documentation to use their config.
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email glpspeiris@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.