PluginBench
Skill
Official
Fail
Audit score 45

chdb-sql

clickhouse/agent-skills

Run ClickHouse SQL on local files, URLs, S3, and remote databases without a server.

What is chdb-sql?

chdb-sql embeds ClickHouse SQL directly in Python, enabling analytical queries on parquet/CSV/JSON files, cloud storage, and remote databases (Postgres, MySQL, MongoDB, ClickHouse Cloud, Iceberg, Delta Lake) with 1000+ SQL functions. Use this when you need to query multiple data sources with advanced SQL features like window functions, cross-source joins, and parametrized queries without server setup.

  • Query local files (parquet, CSV, JSON) and remote data sources with full ClickHouse SQL syntax
  • Join data across multiple sources (databases, S3, data lakes) in a single query
  • Use 1000+ ClickHouse SQL functions including window functions, geo functions, and JSON operations
  • Build stateful multi-step analysis pipelines with Session for persistent or in-memory tables
  • Execute parametrized queries with variable substitution for safe, dynamic SQL
  • Output results in multiple formats (JSON, CSV, DataFrame, Pretty-printed tables)

How to install chdb-sql

npx skills add https://github.com/clickhouse/agent-skills --skill chdb-sql
Prerequisites
  • Python 3.9 or higher
  • macOS or Linux operating system
  • pip install chdb
Claude Code
Cursor
Windsurf
Cline

How to use chdb-sql

  1. 1.Import chdb and run a one-off query with chdb.query() for simple cases
  2. 2.For multi-step analysis, create a Session object and build persistent tables from remote sources
  3. 3.Use table functions like s3(), mysql(), postgresql(), deltaLake(), iceberg() to reference external data
  4. 4.Join tables across different sources in a single SQL statement
  5. 5.Use parametrized queries with params argument to safely pass variables into SQL
  6. 6.Call .show() or specify output format (DataFrame, CSV, JSON) to get results in your preferred format

Use cases

Good for
  • Analyze parquet files with complex aggregations and window functions without loading into memory
  • Join customer data from MySQL with event logs from S3 to find top-performing regions
  • Build a multi-step analytics pipeline that creates temporary tables from various sources and performs cross-joins
  • Query Delta Lake or Iceberg tables directly from cloud storage with SQL
  • Run parametrized analytical queries with date ranges and filters passed as variables
Who it's for
  • Data analysts performing ad-hoc SQL analysis on local and remote data
  • Python developers building data pipelines that query multiple sources
  • Analytics engineers who need ClickHouse SQL power without database administration
  • Teams working with data lakes (Iceberg, Delta) or cloud storage (S3)

chdb-sql FAQ

When should I use chdb-sql vs. chdb-datastore?

Use chdb-sql for analytical SQL queries with window functions, cross-source joins, and ClickHouse-specific features. Use chdb-datastore for pandas-style DataFrame method-chaining operations.

Do I need to set up a ClickHouse server?

No. chdb runs ClickHouse embedded in your Python process; no server installation or network setup required.

Can I query data from multiple sources in one query?

Yes. Use table functions like mysql(), s3(), postgresql(), deltaLake(), and iceberg() to reference different sources and join them in a single SQL statement.

What output formats are supported?

Results can be returned as JSON, CSV, DataFrame, Pretty-printed tables, or raw data depending on the format parameter passed to query().

How do I handle file paths that don't exist?

Verify the file path is absolute or relative to your current working directory. Use the verify_install.py script in the skill directory to check your environment.

Full instructions (SKILL.md)

Source of truth, from clickhouse/agent-skills.


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.

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

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 | SQL functions → sql-functions.md | Full API → api-reference.md

Session — Stateful Analysis Pipelines

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)

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

ProblemFix
ImportError: No module named 'chdb'pip install chdb
DB::Exception: FILE_NOT_FOUNDCheck file path; use absolute path or verify cwd
DB::Exception: Unknown table functionCheck function name spelling (e.g., deltaLake not deltalake)
Connection refused to remote DBCheck host:port format; ensure remote DB allows connections
Environment checkRun python scripts/verify_install.py (from skill directory)

References

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.