Chat2DuckDB Data Analysis
Paste the following prompt into your AI chat to install this skill:
Please install @user_af28adda/chat2duckdb-cloudcba based on the guide at https://skillhub.cn/install/skillhub.md.
About this skill
The Core Problem Being Solved
Data analysis often begins with an unfamiliar file (e.g., CSV, Excel), where engineers face common pain points:
- Inefficient Manual Exploration: Obtaining basic statistics requires writing custom scripts or recalling cumbersome library functions.
- Error-Prone SQL Writing: Manual queries are susceptible to column name typos and syntax oversights (e.g., extra semicolons), leading to repeated debugging.
- Lack of Validation Workflow: Executing complex queries or working directly on large datasets carries risk, with no lightweight mechanism for sampling-based validation.
The Intelligent Data Analysis skill aims to provide an automated analysis flow—from "understanding data" to "gaining insights"—using the DuckDB engine and a natural language interface.
How the Skill Works: Core Capabilities and Key Steps
This skill is built around the SQL analytics capabilities of DuckDB. Its core workflow is as follows:
1. Data Registration and Exploration
- Data files in formats like CSV, JSON, Parquet, etc., are registered as a
datatable in DuckDB using Pandas. - The
describemode generates a complete data profile, including schema, numerical statistics, categorical distributions, date ranges, and missing value counts.
2. Intelligent Query Generation and Execution
- Natural Language to SQL: Converts a user's analytical intent (e.g., "calculate average price by category") directly into a corresponding
SELECTstatement. - Automatic SQL Correction Engine:
- Fixes syntax errors (e.g., extra semicolons, unmatched quotes).
- Intelligently corrects column name errors based on edit distance (e.g., matching
categroytocategory). - Normalizes SQL keyword casing and Chinese punctuation.
- Retries and Sampling: Automatically retries failed queries (default 3 times). Supports quick logic validation on a small sample via the
--sample_fractionparameter.
3. Result Analysis and Persistence
- Outputs the result table, execution time, and retry count.
- Generates business insights based on the results (e.g., percentage contributions, trends).
- Optionally persists analysis results or intermediate tables to a DuckDB database file (via
--persist_db_path), facilitating subsequent multi-table joins.
Applicability Boundaries and Key Caveats
This skill is focused on the DuckDB SQL dialect and is not compatible with proprietary syntax from other databases like MySQL or PostgreSQL. Pay special attention to:
- Explore Before Querying: Always recommend using the describe mode to understand the data structure and quality before constructing queries.
- Validate Complex Queries: For complex queries involving heavy computation or joins, always validate first using sampling parameters (e.g., --sample_fraction 0.1).
- Resource Constraints: When working with very large datasets, combine queries with LIMIT clauses or aggregations to avoid memory issues. Pandas is used only for initial file reading—all analytical computations must be performed via DuckDB SQL to ensure performance and consistency.
- Handling Special Field Names: Fields containing spaces, hyphens, or Chinese characters must be enclosed in double quotes in SQL (e.g., "销售-额"). The skill engine will attempt to auto-correct cases where quotes are omitted.
Adhering to these practices enables an efficient and reliable end-to-end flow from raw data to analytical conclusions.
Use Cases
- When handed a new sales data CSV file, use the data exploration mode to quickly obtain column structures, numerical distributions, and missing value statistics to assess data quality.
- The business team needs to analyze product category performance, generating and executing SQL queries via natural language descriptions (e.g., "calculate last month's sales by category") to directly gain insights.
- Before executing multi-table join queries on a large orders table, first validate the logic on a 10% data sample using the sampling parameter to avoid performance issues from full table scans.
- After completing a query, the results need to be automatically saved as an Excel file for sharing with non-technical colleagues or for creating visual dashboards.
Best For
- Data Analysts: Need to handle multiple new datasets weekly, quickly explore data structures, and write SQL queries to generate periodic reports.
- Business Analysts: Seek to gain sales or operational data insights via natural language descriptions, reducing reliance on SQL syntax knowledge.
- Data Engineers: Integrate automated SQL error correction and retry mechanisms into data processing pipelines to improve stability and fault tolerance.
- Product Managers: Need to regularly analyze user behavior data, using sampling features to safely test different query logic to support product decisions.
Related Skills
A universal base component that automatically launches the Edge browser and connects the BrowserSkill extension, ensuring readiness for web scraping and browser automation tasks.
A fully local-run WeChat chat analysis tool with MBTI personality inference, sentiment analysis, risk detection, relationship health assessment, and conversation prediction, emphasizing privacy.
Fetches the top 20 A-share stocks by trading volume from Wencai, including ranking, price changes, and sectors, with sector analysis.
Performs project discrimination, classification, and structured extraction on bidding documents, outputting standardized data with support for manual review.