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)
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.
Add this badge to a GitHub README so readers can open the package page and install the same version.
[](https://www.aipm-registry.com/skills/clickhouse/chdb-sql/1.0.0?utm_source=github&utm_medium=readme&utm_campaign=package_badge)
This imported publisher has not claimed its AIPM account. A connected account confirms account control, but it does not guarantee that a package is safe.
AI assistant context
What this skill is for
@clickhouse/chdb-sql@1.0.0 is an AIPM skill package for All tools. Use it when a project needs the reusable AI behavior described as: >-
Run aipm add @clickhouse/chdb-sql@1.0.0 in a project that has AIPM initialized.
Supported tools
@clickhouse/chdb-sql@1.0.0 supports All tools.
Before installing
AIPM skills can add files to your project. Review the package name, target, description, license, and publisher before installing. Use a clean branch when trying a new skill.