clickhouse-buffer
TypeScript icon, indicating that this package has built-in type declarations

2.3.0 • Public • Published

clickhouse-buffer

Install

yarn add clickhouse-buffer
# or
npm install clickhouse-buffer

How to use

import {ClickhouseBuffer, DEFAULT_DATABASE} from "clickhouse-buffer";

(async () => {
    const database = DEFAULT_DATABASE;
    const table = 'events';

    const directoryPath = await ClickhouseBuffer.prepareDirectoryPath('buffer', database, table, 0o777);

    const clickhouseBuffer = new ClickhouseBuffer({
        directoryPath,
        database,
        table
    });

    await clickhouseBuffer.clickhouseClient.query(`CREATE TABLE IF NOT EXISTS ${database}.${table} (id UInt16) ENGINE = MergeTree() ORDER BY id`);

    await clickhouseBuffer.loadFilesToDatabase();

    for (let i = 0; i <= 9; i++) {
        clickhouseBuffer.push([i]);
    }

    setTimeout(() => {
        for (let i = 10; i <= 19; i++) {
            clickhouseBuffer.push([i]);
        }
    }, 5000)

    setTimeout(() => {
        clickhouseBuffer.release();
    }, 15000);
})();

Package Sidebar

Install

npm i clickhouse-buffer

Weekly Downloads

0

Version

2.3.0

License

MIT

Unpacked Size

21.6 kB

Total Files

19

Last publish

Collaborators

  • watchdg