{"id":42511,"library":"clickhouse-sql-client","title":"clickhouse-sql-client","description":"A lightweight, TypeScript-based SQL query builder for ClickHouse. Version 1.0.5 provides a fluent API to construct SELECT, INSERT, UPDATE, and DELETE queries with ClickHouse-specific features like PREWHERE, LIMIT BY, and raw expressions. It simplifies generating complex SQL strings without runtime dependencies, supporting subqueries, aggregations, and clickhouse-specific functions. Ideal for Node.js applications needing a type-safe query builder with full ClickHouse dialect support. Maintained on GitHub with sparse updates.","status":"active","version":"1.0.5","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","clickhouse","sql","dialect","clickhouse-sql","clickhouse-client","node-clickhouse","sql-client","client"],"install":[{"cmd":"npm install clickhouse-sql-client","lang":"bash","label":"npm"},{"cmd":"yarn add clickhouse-sql-client","lang":"bash","label":"yarn"},{"cmd":"pnpm add clickhouse-sql-client","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only; CommonJS require is not supported.","wrong":"const ClickhouseQueryBuilder = require('clickhouse-sql-client')","symbol":"ClickhouseQueryBuilder","correct":"import { ClickhouseQueryBuilder } from 'clickhouse-sql-client'"},{"note":"TypeScript types are exported; no separate type import needed.","wrong":"import { QueryBuilder } from 'clickhouse-sql-client/build/main'","symbol":"QueryBuilder","correct":"import { QueryBuilder } from 'clickhouse-sql-client'"},{"note":"SelectBuilder is used as a parameter type; prefer type import.","wrong":"import { SelectBuilder } from 'clickhouse-sql-client'","symbol":"SelectBuilder","correct":"import type { SelectBuilder } from 'clickhouse-sql-client'"}],"quickstart":{"code":"import { ClickhouseQueryBuilder } from 'clickhouse-sql-client';\n\nconst dialect = new ClickhouseQueryBuilder();\n\nconst query = dialect\n  .select(b => b.raw('count(*) as cnt'))\n  .from(b => b.table.name('events'))\n  .where(b => b.and('event_type', '=', 'click'))\n  .groupBy('event_date')\n  .orderBy('cnt DESC')\n  .limit(10)\n  .sql();\n\nconsole.log(query);\n// SELECT count(*) as cnt FROM events WHERE event_type = 'click' GROUP BY event_date ORDER BY cnt DESC LIMIT 10","lang":"typescript","description":"Builds a SELECT query with aggregation, filtering, grouping, ordering, and limit using the query builder pattern."},"warnings":[{"fix":"Use b.raw(\"date = toDateTime('2021-01-01')\") instead of b.and('date', '=', 'toDateTime(...)')","message":"String values in where conditions are not automatically quoted; use raw for expressions.","severity":"gotcha","affected_versions":"*"},{"fix":"Ensure the string is safe; consider using limit(5) without BY for simple cases.","message":"LIMIT BY syntax uses string like '1,2 BY id' – builder does not validate or escape.","severity":"gotcha","affected_versions":"*"},{"fix":"Check source code or tests for other query types, or use raw SQL for mutations.","message":"INSERT, UPDATE, DELETE are not documented; only SELECT builder is shown in README.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'1.0.5':16 'aggreg':52 'api':20 'applic':61 'base':9 'builder':12,68 'clickhous':2,14,31,55,71,81,85,88,92 'clickhouse-cli':87 'clickhouse-specif':30,54 'clickhouse-sql':84 'clickhouse-sql-cli':1 'client':4,89,95,96 'complex':44 'construct':22 'delet':27 'depend':49 'dialect':72,83 'express':40 'featur':33 'fluent':19 'full':70 'function':57 'generat':43 'github':76 'ideal':58 'insert':24 'javascript':80 'lightweight':6 'like':34 'limit':36 'maintain':74 'need':62 'node':91 'node-clickhous':90 'node.js':60 'prewher':35 'provid':17 'queri':11,28,67 'raw':39 'runtim':48 'safe':66 'select':23 'simplifi':42 'spars':78 'specif':32,56 'sql':3,10,45,82,86,94 'sql-client':93 'string':46 'subqueri':51 'support':50,73 'type':65 'type-saf':64 'typescript':8 'typescript-bas':7 'updat':25,79 'version':15 'without':47","created_at":"2026-06-05T16:55:19.600708+00:00","updated_at":"2026-06-05T16:55:19.600708+00:00","problems":[{"fix":"Use import { ClickhouseQueryBuilder } from 'clickhouse-sql-client'","cause":"Using CommonJS require instead of ESM import.","error":"TypeError: ClickhouseQueryBuilder is not a constructor"},{"fix":"Run npm install clickhouse-sql-client","cause":"Package not installed or typo in package name.","error":"Cannot find module 'clickhouse-sql-client'"},{"fix":"Chain .sql() at the end of the builder call.","cause":"Forgetting to call .sql() after building the query.","error":"Property 'sql' does not exist on type 'QueryBuilder'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://bitbucket.org/bytdnel/clickhouse-sql-client#readme","github":null,"docs":null,"changelog":null,"pypi":null,"npm":"clickhouse-sql-client","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}