Skip to main content
skill Claude Code CX Codex Cursor GitHub Copilot

chdb-sql — Claude Code skill: what it does, how to install

A skill that teaches your agent analytical SQL over parquet, CSV, S3 and remote databases with chDB, which is ClickHouse running inside Python. No server to start.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add ClickHouse/agent-skills --skill chdb-sql -a claude-code
Open on GitHub

What chdb-sql does

The skill hands the agent the actual chDB syntax. A query can hit local parquet, CSV or JSON files, a URL, an S3 path, or a remote Postgres, MySQL, MongoDB, ClickHouse Cloud, Iceberg or Delta Lake source. The table functions s3(), mysql(), postgresql(), iceberg(), deltaLake() and remoteSecure() join like ordinary tables, so an orders file next to a CRM table is one SELECT rather than two scripts glued together.

Inside there is a decision tree. chdb.query() for a single shot, Session for a multi-step pipeline that keeps tables on disk, chdb.connect() when you want DB-API 2.0. Reference files cover table functions, SQL functions and call signatures, the examples come with expected output, and scripts/verify_install.py checks the environment. Values go in through params instead of string building.

You need Python 3.9+ and pip install chdb; compatibility lists macOS and Linux, so a Windows machine is worth checking before you commit to it. The skill stays clear of pandas-style method chaining, which belongs to chdb-datastore, and of ClickHouse server administration.

What it helps with

  • run analytics on a parquet file without starting a server
  • join a MySQL table with a local CSV in one query
  • query an S3 bucket from a throwaway Python script
  • keep intermediate tables across steps with Session
  • pass a date into a query through params instead of string concatenation

Example prompts for the agent

  • Run a chdb query over `orders.parquet` and show revenue by country.
  • Join `users` from MySQL with the local `events.csv` and group by country.
  • Open a `Session` in `./analytics_db`, load the S3 parquet into it and count weekly active `user_id`s.

How to install chdb-sql

1Skills CLI (Vercel)

npx skills add ClickHouse/agent-skills --skill chdb-sql -a claude-code

2Manually: put the files in place

~/.claude/skills/chdb-sql/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/chdb-sql/

From the same set2

The whole set →

Similar

firecrawl-lead-research firecrawl Pulls job title, company and firmographics for the people and domains you already named, then fills the gaps in a list. Useful before a call or when an old lead list needs a check. Claude Code CX Codex Cursor +1 31,400installs pm-skills Alireza Rezvani Routes project-delivery requests across 8 PM sub-skills for Jira, Confluence, sprints, reporting, and team communication. Useful for controlled delivery work. Claude Code 1,975installs insforge-integrations InsForge A skill that walks your agent through hooking a third-party auth provider into InsForge and through taking x402 payments on an HTTP endpoint. Claude Code CX Codex Cursor +1 55,700installs connecting-to-data-source aws Builds and tests an AWS Glue connection to Oracle, PostgreSQL, Redshift, Snowflake or BigQuery, so a job does not discover the wiring is wrong at runtime. Claude Code CX Codex Cursor +1 6,800installs querying-data-lake aws A skill that runs SQL in Amazon Athena: it picks a workgroup, stops destructive statements for confirmation and reports what the query cost. Claude Code CX Codex Cursor +1 6,600installs senior-backend Alireza Rezvani Scaffolds backend APIs, detects database bottlenecks, and runs load tests. Useful when designing Express routes, optimizing PostgreSQL, or preparing for production. Claude Code 1,674installs xlsx official anthropics Creates, reads, edits, and converts spreadsheet files. Use it when the requested deliverable is an Excel workbook or another tabular file. Claude Code Claude.ai 187,223installs google-agents-cli-observability official Google This skill guides you through tracing and monitoring AI agents, including ADK agents. Use it when you need to inspect agent execution or monitor a deployed agent. Claude Code CX Codex Cursor +1 509,900installs

Questions about chdb-sql

How do I install chdb-sql in Claude Code?

Run npx skills add ClickHouse/agent-skills --skill chdb-sql -a claude-code. The skill file lands at ~/.claude/skills/chdb-sql/SKILL.md.

What does chdb-sql do?

It gives the agent chDB query syntax: analytical SQL over local files, S3 and remote databases, including joins that mix sources in one SELECT.

What do I need before using it?

Python 3.9+ and the chdb package from pip install chdb. Compatibility covers macOS and Linux.

Source text

SKILL.md · Apache-2.0
---
name: chdb-sql
description: >-
  Use when the user wants to run SQL — especially analytical SQL — on
  local files (parquet/csv/json), URLs, S3 paths, or remote databases
  (Postgres, MySQL, MongoDB, ClickHouse Cloud, Iceberg, Delta Lake)
  without setting up a server. Provides chDB — embedded ClickHouse SQL
  in Python with 1000+ functions, Session for stateful multi-step
  pipelines, parametrized queries, and cross-source joins via `s3()`,
  `mysql()`, `postgresql()`, `iceberg()`, `deltaLake()`, `remoteSecure()`
  table functions.
  TRIGGER when: user wants SQL on parquet/csv/files or across remote
  analytical sources; uses ClickHouse SQL features (window functions,
  windowFunnel, geoToH3, JSON path ops, Session, parametrized queries);
  imports `chdb` or calls `chdb.query()`.
  SKIP this skill for pandas-style DataFrame method-chaining (use
  chdb-datastore instead) or ClickHouse server administration.
license: Apache-2.0
compatibility: Requires Python 3.9+, macOS or Linux. pip install chdb.
metadata:
  author: chdb-io
  version: "4.1"
  homepage: https://clickhouse.com/docs/chdb
---

# chdb SQL — ClickHouse in Your Python Process

Run ClickHouse SQL directly in Python — no server needed. Query local files, remote databases, and cloud storage with full ClickHouse SQL power.

```bash
pip install chdb
```

## Decision Tree: Pick the Right API

```
1. One-off query on files or databases → chdb.query()
2. Multi-step analysis with tables      → Session
3. DB-API 2.0 connection                → chdb.connect()
4. Pandas-style DataFrame operations    → Use chdb-datastore skill instead
```

## chdb.query() — One Line, Any Data

```python
import chdb

chdb.query("SELECT * FROM file('data.parquet', Parquet) WHERE price > 100 LIMIT 10")       # local files
chdb.query("SELECT * FROM mysql('db:3306', 'shop', 'orders', 'root', 'pass')")              # databases
chdb.query("SELECT * FROM s3('s3://bucket/data.parquet', NOSIGN) LIMIT 10")                 # cloud storage
chdb.query("SELECT * FROM deltaLake('s3://bucket/delta/table', NOSIGN) LIMIT 10")           # data lakes

# Cross-source join
chdb.query("""
    SELECT u.name, o.amount FROM mysql('db:3306', 'crm', 'users', 'root', 'pass') AS u
    JOIN file('orders.parquet', Parquet) AS o ON u.id = o.user_id ORDER BY o.amount DESC
""")

data = {"name": ["Alice", "Bob"], "score": [95, 87]}
chdb.query("SELECT * FROM Python(data) ORDER BY score DESC")                                # Python data
df = chdb.query("SELECT * FROM numbers(10)", "DataFrame")                                   # output formats
chdb.query("SELECT toDate({d:String}) + number FROM numbers({n:UInt64})",
    "DataFrame", params={"d": "2025-01-01", "n": 30})                                      # parametrized
```

Table functions → [table-functions.md](references/table-functions.md) | SQL functions → [sql-functions.md](references/sql-functions.md) | Full API → [api-reference.md](references/api-reference.md)

## Session — Stateful Analysis Pipelines

```python
from chdb import session as chs
sess = chs.Session("./analytics_db")   # persistent; Session() for in-memory

sess.query("CREATE TABLE users ENGINE=MergeTree() ORDER BY id AS SELECT * FROM mysql('db:3306','crm','users','root','pass')")
sess.query("CREATE TABLE events ENGINE=MergeTree() ORDER BY (ts,user_id) AS SELECT * FROM s3('s3://logs/events/*.parquet',NOSIGN)")
sess.query("""
    SELECT u.country, count() AS cnt, uniqExact(e.user_id) AS users
    FROM events e JOIN users u ON e.user_id = u.id
    WHERE e.ts >= today() - 7 GROUP BY u.country ORDER BY cnt DESC
""", "Pretty").show()
sess.close()
```

## Connection API (DB-API 2.0)

```python
from chdb import dbapi
conn = dbapi.connect()
cur = conn.cursor()
cur.execute("SELECT * FROM file('data.parquet', Parquet) WHERE value > 100")
print(cur.fetchall())
cur.close()
conn.close()
```

## Troubleshooting

| Problem | Fix |
|---------|-----|
| `ImportError: No module named 'chdb'` | `pip install chdb` |
| `DB::Exception: FILE_NOT_FOUND` | Check file path; use absolute path or verify cwd |
| `DB::Exception: Unknown table function` | Check function name spelling (e.g., `deltaLake` not `deltalake`) |
| Connection refused to remote DB | Check host:port format; ensure remote DB allows connections |
| Environment check | Run `python scripts/verify_install.py` (from skill directory) |

## References

- [API Reference](references/api-reference.md) — query/Session/connect signatures
- [Table Functions](references/table-functions.md) — All ClickHouse table functions
- [SQL Functions](references/sql-functions.md) — Commonly used SQL functions
- [Examples](examples/examples.md) — 9 runnable examples with expected output
- [Official Docs](https://clickhouse.com/docs/chdb)

> Note: This skill teaches how to *use* chdb SQL.
> For pandas-style operations, use the `chdb-datastore` skill.
> For contributing to chdb source code, see CLAUDE.md in the project root.

© chdb-io · Apache-2.0 · ClickHouse/agent-skills

See also

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor