sql-runner

Execute SQL files via Dataphin MCP and export result sets as CSV files.

1|Updated Apr 1, 2026
One-click install
npx skills add https://github.com/OliverOuyang/shuhe-work-skills --skill sql-runner
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-runner
Source: https://github.com/OliverOuyang/shuhe-work-skills/tree/main/skills/sql-runner
Command: npx skills add https://github.com/OliverOuyang/shuhe-work-skills --skill sql-runner

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Automates running SQL files against Dataphin, removing manual submission, polling, and result-saving steps so analysts can get query outputs as ready-to-open CSVs without handling MCP calls or file management.

Core Features & Use Cases

  • File-driven execution: Reads a local SQL file, extracts a query name from header comments or falls back to the filename.
  • MCP integration & polling: Submits queries via the sh_dp_mcp protocol, polls status at regular intervals, enforces a 5-minute timeout and can kill timed-out tasks.
  • Result management: Saves results as UTF-8 with BOM CSV files in a data/ subfolder with sanitized, timestamped filenames and reports row counts.
  • Robust error handling: Detects permission issues, syntax errors, connection failures, and empty results and provides actionable messages.
  • Use case examples: Ad-hoc analytics, scheduled data extraction, exporting query results for downstream reporting or analysis.

Quick Start

Run the SQL file at /path/to/query.sql and save the results as a timestamped CSV in the data/ subfolder.

Frequently Asked Questions about sql-runner

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automate SQL query execution on Dataphin and export results to CSV?

Dataphin SQL execution automates submitting local SQL files to Dataphin MCP, polling query status, and saving result sets as UTF-8 BOM CSV files. This removes manual submission and polling steps for analysts.

What happens when a Dataphin query times out or fails?

When Dataphin query timeout handling enforces a 300s limit, polling status every 5s, and kills timed-out tasks. It detects permission issues, syntax errors, and connection failures, providing actionable error messages.

Does the Dataphin MCP integration support sequential SELECT statements in one file?

Yes, Dataphin MCP integration supports local SQL files containing single or sequential SELECT statements. It extracts query names from header comments or falls back to the filename for result management.

How are CSV export files named and encoded when running SQL queries?

CSV export files are encoded as UTF-8 with BOM and saved in a data/ subfolder. Filenames are sanitized and timestamped based on header comments or the original SQL filename, with reported row counts.

Can I use this for scheduled data extraction and ad-hoc analytics?

Yes, this SQL execution workflow suits scheduled data extraction and ad-hoc analytics. It automates query submission, polling, and result-saving steps to generate ready-to-open CSVs for downstream reporting.