Socket
Socket
Sign inDemoInstall

clickhouse-ts

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clickhouse-ts

Clickhouse client on TypeScript using nodejs ot redis caching queries


Version published
Weekly downloads
110
decreased by-20.29%
Maintainers
1
Weekly downloads
 
Created
Source

clickhouse-ts

TS client for clickhouse database with using redis/nodejs caching rows for bulk insertion

import { Clickhouse } from 'clickhouse-ts'
import fs from 'fs'
import { serializeError } from 'serialize-error'

const client = new Clickhouse(
  {
    url: 'url',
    port: 8443,
    user: 'user',
    password: 'password',
    database: 'database',
    ca: fs.readFileSync('cert.crt')
  },
  {
    /*
      cacheClient: 'system' | 'redis' | undefined
      if 'system', Node.js will accumulate insert rows filtered by table name and insert by interval or overflowing
      if 'redis' Redis client will do the same
      if nothing package will not use caching
    */
    cacheClient: 'system',
    defaultResponseFormat: 'JSON',
    clickhouseOptions: {
      /*
        any clickhouse options
        https://clickhouse.tech/docs/en/operations/settings/settings/
      */
      send_progress_in_http_headers: '1'
    }
  }
)

client
  .query('WITH now() as t SELECT t', {
    responseFormat: 'TSV',
    // ...another query options
  })
  .then(result => result.data.data)
  .catch(e => serializeError(e))

client
  .insert(
    'strings',
    [{ date: '2021-01-01', string: 'string' }],
    {
      responseFormat: 'CSVWithNames' // or another format
      // another query options
    }
  )
  .then(response => response)
  .catch(e => serializeError(e))

Keywords

FAQs

Package last updated on 24 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc