clickhouse 0.2.0 copy "clickhouse: ^0.2.0" to clipboard
clickhouse: ^0.2.0 copied to clipboard

A fast, native Dart driver for ClickHouse over the TCP binary protocol — queries, batch inserts, connection pooling, LZ4/LZ4HC/ZSTD compression, and full column-type support.

example/clickhouse_example.dart

import 'package:clickhouse/clickhouse.dart';

void main() async {
  // ── Direct connection ────────────────────────────────────────────────────
  final conn = await ClickHouseConnection.connect(ClickHouseOptions(
    host: 'localhost',
    port: 9000,
    database: 'default',
    username: 'default',
    password: '',
    compress: true,
  ));

  // DDL
  await conn.exec('CREATE TABLE IF NOT EXISTS demo ('
      'id UInt32, name String, score Float64'
      ') ENGINE = MergeTree() ORDER BY id');

  // INSERT via batch
  final batch = await conn.prepareBatch('INSERT INTO demo');
  batch.addRow([1, 'Alice', 9.5]);
  batch.addRow([2, 'Bob', 8.2]);
  await batch.send();

  // SELECT
  final rows = await conn.query('SELECT id, name, score FROM demo ORDER BY id');
  while (await rows.next()) {
    final row = rows.currentRow;
    print('id=${row[0]}  name=${row[1]}  score=${row[2]}');
  }
  await rows.close();

  await conn.exec('DROP TABLE IF EXISTS demo');
  await conn.close();

  // ── Connection pool ──────────────────────────────────────────────────────
  final pool = ClickHousePool(
    options: const ClickHouseOptions(host: 'localhost'),
    maxOpen: 5,
  );

  final alive = await pool.ping();
  print('Pool ping: $alive');

  await pool.close();
}
0
likes
150
points
129
downloads

Documentation

API reference

Publisher

verified publishershreyanshchaudhary.in

Weekly Downloads

A fast, native Dart driver for ClickHouse over the TCP binary protocol — queries, batch inserts, connection pooling, LZ4/LZ4HC/ZSTD compression, and full column-type support.

Repository (GitHub)
View/report issues
Contributing

License

MIT (license)

Dependencies

meta, timezone

More

Packages that depend on clickhouse