npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@founderpath/kysely-clickhouse

v2.0.0

Published

Clickhouse Dialect for Kysely

Readme

@founderpath/kysely-clickhouse

Kysely adapter for Clickhouse.

npm i @clickhouse/client @founderpath/kysely-clickhouse

This project was largely adapted from kysely-planetscale. It's a barebone version, there's a lot of improvements that can be done here.

Usage

Pass your Clickhouse connection options into the dialect in order to configure the Kysely client. Follow these docs for instructions on how to do so.

import { Kysely } from 'kysely';
import { ClickhouseDialect } from '@founderpath/kysely-clickhouse';

interface SomeTable {
  key: string;
  value: string;
}

interface Database {
  some_datasets.some_table: SomeTable
}

const db = new Kysely<Database>({ dialect: new ClickhouseDialect() });

How values are sent

ClickHouse has no prepared statements over HTTP, so the dialect writes every parameter into the SQL as an escaped literal:

| JavaScript | ClickHouse | | --- | --- | | string | 'text', with quotes and backslashes escaped | | number, bigint | number literal | | boolean | true / false | | null | NULL | | Date | toDateTime64('2024-04-01 12:34:56.789', 3, 'UTC') | | array | [...] | | other objects | their JSON, as a string |

undefined is rejected with an error instead of being sent. A parameter cannot be placed inside a comment or a quoted token of a sql template.

A ? written directly in raw SQL is read as a placeholder, so ClickHouse's a ? b : c operator cannot be used in sql templates. Use if(a, b, c).

Dates

A Date used as a parameter (where, set, sql templates) is the same instant whatever the time zone of the server or the column, and can be compared with Date, DateTime and DateTime64 columns.

Rows passed to insertInto().values() are sent as JSON, where a Date becomes an ISO 8601 string. DateTime and DateTime64 columns accept it because the dialect sets date_time_input_format to best_effort. Date and Date32 columns do not: ClickHouse only reads YYYY-MM-DD there, so pass a string for those.

Settings

options.clickhouse_settings is applied to every query, and takes precedence over the date_time_input_format default above:

new ClickhouseDialect({
  options: {
    url: 'http://localhost:8123',
    clickhouse_settings: {
      // ClickHouse 25.8 and later return 64-bit integers as JSON numbers, which lose precision
      // above 2^53 in JavaScript. This returns them as strings, as older versions do.
      output_format_json_quote_64bit_integers: 1,
    },
  },
})

All queries of a Kysely instance share one ClickHouse client, which is closed by db.destroy(). The number of sockets it opens is not limited unless you set options.max_open_connections.

Development

The tests need a ClickHouse server:

pnpm test:up
pnpm test

Set CLICKHOUSE_PORT for both commands if port 8123 is already in use.