duckdb
Use DuckDB for analytical SQL over local CSV, JSON, Parquet, and Excel files - aggregations, joins, window functions, statistics, and data profiling without…
от lanej★ 41 звезда на GitHub
Установить duckdb в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
DuckDB
SQL over local files with no import step. Standard SQL and DuckDB's file-reading functions work as documented; this file covers tool selection, file access, concurrency, and Python API traps.
When to reach for it
Yes: aggregations, GROUP BY, window functions, joins across datasets, percentiles and summary statistics, profiling, transformations before export.
No: viewing a file (xsv, xlsx, cat), single-row lookups (grep, jq), simple column filtering (xsv is less ceremony).
Reading files
Query paths directly — globs, and format detection, both work:
SELECT * FROM 'data.csv' LIMIT 10;
SELECT * FROM 'data/*.parquet';
DESCRIBE SELECT * FROM 'data.csv'; -- inspect inferred types before trusting them
Parquet is fastest (columnar, predicate pushdown). Convert large CSVs once if you'll query them repeatedly: COPY (SELECT * FROM 'big.csv') TO 'big.parquet' (FORMAT PARQUET);
Piping
DuckDB reads stdin via /dev/stdin, so it chains with the rest of the toolchain:
xsv search -s status "active" data.csv | duckdb -c "SELECT AVG(amount) FROM read_csv('/dev/stdin')"
jq -c '.' events.json | duckdb -c "SELECT COUNT(*) FROM read_json_auto('/dev/stdin')"
conform extract messy_report.pdf --output invoices.csv && duckdb -c "SELECT vendor, SUM(amount) FROM 'invoices.csv' GROUP BY 1"
duckdb -c "COPY (SELECT * FROM 'local.csv' WHERE important) TO 'important.csv'" && bigquery insert dataset.table important.csv
Concurrency: a read-write connection takes an exclusive file lock
Opening a .duckdb file in read-write mode (the default for duckdb.connect(path) and any wrapper class that always opens rw) takes an exclusive OS-level lock on that file — a second process cannot open any connection to it concurrently, not even a read-only one, until the first connection closes. Before parallelizing sub-agent tasks that touch a shared .duckdb file, check whether the accessor opens it read-write unconditionally — if so, serialize those specific steps instead of running them concurrently, even if the rest of the plan's tasks are otherwise independent. Open with read_only=True explicitly wherever a step only needs to read.
Python API gotchas
rowcount is always negative for UPDATE/DELETE
con.execute("UPDATE ...") then .rowcount returns -1 (or a negative multiple in a loop), not the affected row count. The statement did run. To report a count, run the equivalent SELECT COUNT(*) with the same WHERE clause first:
affected = con.execute(
"SELECT COUNT(*) FROM users WHERE last_login < '2024-01-01'"
).fetchone()[0]
con.execute("UPDATE users SET active = false WHERE last_login < '2024-01-01'")
.fetchall() / .df() on SELECT are unaffected — they return real results.
.df().to_dict(orient="records") coerces types
SQL NULLs arrive as typed pandas NA, not None, and several types are not JSON-serializable:
| DuckDB type | pandas representation | symptom |
|---|---|---|
| NULL VARCHAR/INTEGER | float('nan') |
AttributeError: 'float' object has no attribute 'lower' |
| NULL TIMESTAMP | pd.NaT |
fromisoformat: argument must be str; not JSON serializable |
| TIMESTAMP | pd.Timestamp |
not JSON serializable — needs .isoformat() |
| ARRAY/LIST | numpy.ndarray |
not JSON serializable — needs .tolist() |
Sanitize before passing rows downstream:
import math, numpy as np, pandas as pd
row = {
k: (None if (isinstance(v, float) and math.isnan(v)) or v is pd.NaT
else v.isoformat() if isinstance(v, pd.Timestamp)
else v.tolist() if isinstance(v, np.ndarray)
else v)
for k, v in row.items()
}
Pass allow_nan=False to json.dumps as a safety net — it raises on a leftover NaN rather than silently emitting invalid NaN.
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл duckdb?
Use DuckDB for analytical SQL over local CSV, JSON, Parquet, and Excel files - aggregations, joins, window functions, statistics, and data profiling without an import step.
Как установить скилл duckdb?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл duckdb запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
AnthropicCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
discernment-nudge
AnthropicAfter you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
data-consolidate
AnthropicJoins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
inspection-to-capa
AnthropicRuns the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…