Agent Native

chdb-sql

The skill enables running ClickHouse SQL queries on local files (parquet, csv, json), remote databases (Postgres, MySQL, MongoDB, ClickHouse Cloud), and cloud…

by ClickHouseOfficial publisherNot reviewed

Identity proven by GitHub's verified organisation badge (ClickHouse)

Agents
Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode
License
Apache-2.0 (permissive)
Pin
356a8c1pinned Oct 9, 2026
Context cost
about 960 tokenswhen the skill loads
GitHub stars
544on clickhouse/agent-skills
Scripts
1 script

What it does

“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.”
The author's description, from SKILL.md

Generated summary from the skill's own text

The skill enables running ClickHouse SQL queries on local files (parquet, csv, json), remote databases (Postgres, MySQL, MongoDB, ClickHouse Cloud), and cloud storage (S3, Iceberg, Delta Lake) directly in Python without a server. It provides chdb.query() for one-off queries, Session for multi-step analytical pipelines, and supports over 1000 SQL functions including window functions, geospatial operations, and JSON path queries.

When to use it

  • Running SQL on parquet, CSV, or JSON files locally or via URLs
  • Analyzing data across multiple remote sources with SQL joins
  • Building multi-step data pipelines using Session for stateful queries
  • Using advanced ClickHouse features like window functions or geospatial operations

When not to

  • Need pandas DataFrame method chaining operations instead of SQL
  • Administering ClickHouse servers or managing server infrastructure
  • Working exclusively with in-memory Python data structures without files

Install

These commands install from the publisher's repository and need no account.

skills CLI

npx skills add clickhouse/agent-skills --skill chdb-sql

Installs from the repository's default branch, which may have changed since the commit we checked.

GitHub CLI 2.90 or later

gh skill install clickhouse/agent-skills chdb-sql@356a8c1b9a7392adb389a132f5ad3fec38532a03

Installs the commit we checked (356a8c1).

Copy by hand

Download the folder at 356a8c1 and put it in .claude/skills/chdb-sql for Claude Code and in .agents/skills/chdb-sql for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.

Skill folder on GitHub at 356a8c1

Claude Code plugin

/plugin install clickhouse@claude-plugins-official

The publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.

Claude Code plugin

/plugin install clickhouse-best-practices@claude-plugins-official

The publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.

Copy for your agent

A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.

Prompt

Install the agent skill "chdb-sql" by ClickHouse.

Source, pinned to commit 356a8c1b9a7392adb389a132f5ad3fec38532a03:
https://github.com/clickhouse/agent-skills/tree/356a8c1b9a7392adb389a132f5ad3fec38532a03/skills/chdb-sql

1. Download that folder at exactly this commit. Do not use the default branch.
2. Copy every file unchanged, keeping the folder structure, into .claude/skills/chdb-sql/ for Claude Code and .agents/skills/chdb-sql/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist.
3. Do not edit the files, and do not run any script in the folder unless I ask you to.
4. When you are done, list the files you copied and where you put them.

Listing and checks: https://www.agentnative.dev/skills/clickhouse/chdb-sql

SKILL.md at the pin

---
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.

From clickhouse/agent-skills at 356a8c1, shown as plain text under its license: Apache-2.0 (permissive). The license text is in skills/chdb-sql/SKILL.md.

View SKILL.md on GitHub at 356a8c1

Files

8 files, 41 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.

Skill folder on GitHub at 356a8c1
All 15 skills from ClickHouse

More from ClickHouse

  • chdb-datastore

    This skill enables working with tabular data using a pandas-compatible API backed by ClickHouse for faster execution.

    Contains scripts

    Claude Code, Codex, Cursor +3 · about 1.2K tokens · pinned 6 days ago

  • clickhouse-architecture-advisor

    This skill guides agents through ClickHouse architecture decisions for specific workloads like observability, SIEM, and financial services.

    Claude Code, Codex, Cursor +4 · about 690 tokens · pinned 6 days ago

  • clickhouse-best-practices

    This skill provides 31 ClickHouse best practices rules covering schema design, query optimization, data ingestion, and agent connectivity.

    Claude Code, Codex, Cursor +4 · about 2.5K tokens · pinned 6 days ago

  • clickhouse-js-node-rowbinary

    This skill generates TypeScript/JavaScript code to read and write ClickHouse RowBinary format streams in Node.js.

    Contains scripts

    Claude Code, Codex, Cursor +3 · about 1.2K tokens · pinned 6 days ago

  • clickhouse-js-node-troubleshooting

    Diagnose and fix issues with the ClickHouse Node.js client (@clickhouse/client) running in Node.js environments.

    Claude Code, Codex, Cursor +4 · about 1.1K tokens · pinned 6 days ago

  • clickhouse-managed-postgres-rca

    This skill diagnoses performance problems on ClickHouse-managed Postgres instances by scraping Prometheus metrics and querying the Slow Query Patterns API to…

    Claude Code, Codex, Cursor +4 · about 1.1K tokens · pinned 6 days ago

  • prisma-orm-setup

    This skill sets up Prisma ORM in new applications, defaulting to version 8, or connects and troubleshoots existing Prisma 6, 7, or 8 applications.

    by PrismaOfficial publisher

    Claude Code, Codex, Cursor +4 · about 1.6K tokens · pinned 6 days ago

  • prisma-8

    This skill helps agents work with Prisma 8, a contract-first data layer for TypeScript projects.

    by PrismaOfficial publisher

    Contains scripts

    Claude Code, Codex, Cursor +3 · about 3.5K tokens · pinned 6 days ago

  • dsql

    This skill enables agents to build and manage Aurora DSQL, a serverless PostgreSQL-compatible distributed SQL database.

    by Amazon (AWS)Official publisher

    Contains scripts

    Claude Code, Codex, Cursor +3 · about 6.5K tokens · pinned 6 days ago

  • infra-postgres

    This skill sets up and manages Postgres databases using the clickhousectl CLI.

    by ClickHouseOfficial publisher

    Contains scripts

    Claude Code, Codex, Cursor +3 · about 570 tokens · pinned 6 days ago

  • prisma-next-contract

    This skill enables editing the Prisma Next data contract, the single source of truth for your data layer.

    by PrismaOfficial publisher

    Claude Code, Codex, Cursor +4 · about 6.9K tokens · pinned 6 days ago

  • prisma-next-migrations

    Author and execute Prisma Next migrations by choosing between quick database updates or formal migration plans with data transforms.

    by PrismaOfficial publisher

    Claude Code, Codex, Cursor +4 · about 10K tokens · pinned 6 days ago

The skills listed here are third-party software, collected from public GitHub repositories as a catalog of recent skills and provided as is. Agent Native does not write or control them and is not responsible for any harm, loss or damage caused by installing or using them. Labels and checks describe what we saw at one commit and are not a guarantee. Read a skill's files before you run it. Terms of use