SQL Report Generator: Structuring SQL Query Results into Exportable Reports

Preface

After running SQL and even generating charts, the final step often involves manually piecing together HTML or PPT: writing tables, matrices, filters, and captions separately, resulting in inconsistent export formats. If you want an Agent to generate “deliverable” reports according to a fixed structure and produce insights using statistical methods on real data—rather than fabricating conclusions verbally—you need to clearly define the report components and export workflow at the Skill layer. The following introduces the positioning and usage of the SQL Report Generator on SkillHub.

What is this

SQL Report Generator (slug: sql-report-generator) is a reporting layer Skill for data analysis pipelines: it organizes SQL query results, existing charts, or DataFrames into production-grade reports. It supports various interactive components and HTML / JSON / PDF exports, and provides a pandas-based automatic insights module (without relying on external LLM APIs).

In the SkillHub community, this Skill is categorized under data-analysis, with approximately 984 downloads and a rating of 97207 (platform metrics). It can currently be installed via the SkillHub package @indiv-yaoyao/sql-report-generator, version 1.0.0. The official address provided in the task leads is:

https://api.skillhub.cn/user_64e5b706/sql-report-generator

(This API page was unavailable at the time of scraping; installation and documentation should be based on the @indiv-yaoyao/sql-report-generator resolved by the SkillHub CLI.) Skill details page: https://skillhub.cn/skills/sql-report-generator.

It can be chained with sql-master (data layer) and sql-dataviz (visualization layer), or used independently when data/charts already exist.

Core Functions

The following capabilities are derived from the Skill’s built-in SKILL.md and script descriptions.

Report Components and Export

  • 8 Interactive Components: Table, Matrix, Slicer, Button Navigation, Image Visual, Text Box & Shape, Paginated Report, Report Generator (ReportBuilder).
  • Export Formats: HTML (recommended), JSON (for integration and secondary rendering), PDF (requires additional installation of reportlab, pypdf2).
  • Dashboard Templates: dashboard_templates.py defines 17 industries and 36 preset templates; .md files under templates/ can be generated or updated via scripts/generate_templates.py.

Automatic Insights (scripts/ai_insights.py)

Based on pure statistical analysis (pandas / numpy / scipy) without requiring external AI APIs, it generates structured insights and operational recommendations from DataFrames, outputting Markdown, HTML, or JSON. The analysis types listed in the documentation include: Anomaly Detection (Z-score, IQR, Period-over-Period mutation), Trends (Linear Regression), Correlation (Pearson), TOP N / Pareto, Distribution, Seasonality, Comparative Analysis, etc.

The Skill explicitly requires: when integrating with real data, insights and recommendations must be derived through the aforementioned analysis; handwritten copy that “looks like analysis” is prohibited. External phrasing should use neutral terms such as “Insight Analysis” or “Statistical Analysis.”

Collaboration Modes

Mode Combination Scenario
Standalone sql-report-generator Charts or data already exist; only layout and export needed
Visualization Report sql-dataviz + sql-report-generator No SQL; charts go into the report
Data Report sql-master + sql-report-generator SQL results go directly into the report
Full Pipeline sql-master + sql-dataviz + sql-report-generator Query, charts, and report in one streamlined process

Degraded Capabilities without Python Dependencies

If dependencies cannot be installed, the Skill can still provide report structure suggestions, scenario template recommendations, and display specifications; however, it cannot generate tables/matrices/slicers, export HTML/PDF, run automatic insights, or link with sql-master / sql-dataviz.

Installation and Activation

1. Install SkillHub CLI (if not already installed)

Check or install the CLI according to the official SkillHub installation instructions:

command -v skillhub && skillhub --version

If not installed, you can execute (full installation, including default Skills):

curl -fsSL https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/install.sh | bash

2. Install the Skill to the current Agent’s skills directory

During installation, you must use --dir to point to the skills directory recognized by the current environment; otherwise, it defaults to ./skills/ and may fail to load. Common path examples (excerpted from SkillHub installation docs):

  • Cursor: ~/.cursor/skills/
  • Claude Code: ~/.claude/skills/
  • Codex: ~/.codex/skills/ or .agents/skills/ under the project

Install SQL Report Generator:

skillhub install sql-report-generator --namespace indiv-yaoyao --dir ~/.cursor/skills/

Replace ~/.cursor/skills/ with the path for the Agent you are currently using. The community page also suggests referring to https://skillhub.cn/install/skillhub.md to install @indiv-yaoyao/sql-report-generator.

3. Install Python Dependencies

Python 3 and pip are required before the first use of the Skill. It is recommended to execute within the Skill directory or project environment:

pip install -r requirements.txt

The core dependencies in requirements.txt are: pandas>=1.5.0, numpy>=1.21.0, matplotlib>=3.5.0, jinja2>=3.1.0; the documentation also suggests installing scipy as needed. PDF export requires reportlab and pypdf2.

The Skill documentation also provides a one-click command (depending on the skillhub_install toolchain, if configured in your environment):

skillhub_install install_skill sql-report-generator

After installation, reload or restart the client (e.g., Cursor) to discover the new Skill.

Typical Usage

Generating an HTML Report with ReportBuilder

This step demonstrates the minimal closed loop: metadata, title/body, tables, and HTML export.

from sql_report_generator.scripts.interactive_components import (
    ReportBuilder, TableChart
)

report = ReportBuilder()
report.set_metadata(
    title='Monthly Performance Report',
    author='Data Analysis Team',
    date='2026-03-26'
)

report.add_title('Monthly Performance Report', level=1)
report.add_text('This report summarizes the key performance indicators for this month.')

table = TableChart()
table_b64 = table.create({
    'columns': ['Order ID', 'Customer', 'Amount', 'Date'],
    'rows': [
        ['ORD001', 'Zhang San', '¥1,000', '2026-03-26'],
        ['ORD002', 'Li Si', '¥2,500', '2026-03-25']
    ],
    'title': 'Order List'
})
report.add_table('Order Data', table_b64)

report.export_html('report.html')

Performing Automatic Insights on a DataFrame

On a DataFrame resulting from queries or read from a CSV, invoke the insights module to generate paragraphs embeddable in the report:

from scripts.ai_insights import quick_insights

report = quick_insights(df, date_col="date", value_cols=["sales", "quantity"])
print(report.to_markdown())
print(report.to_html())

Before delivering HTML/PDF, the Skill requires a self-check: whether charts render, whether Chinese and numbers display correctly, whether KPIs match charts, and whether any template placeholders (like {s:,.0f}) remain.

Selecting Industry Dashboard Templates

When needing to quickly align report structures by industry, use the template API:

from sql_report_generator.scripts.dashboard_templates import DashboardGenerator

generator = DashboardGenerator()
template = generator.get_template("E-commerce", "ecommerce_overview")
md = generator.generate_dashboard_markdown(template)

To update local templates/*.md, execute inside the Skill package:

python scripts/generate_templates.py

Scenarios and Notes

Who it is for

  • Data analysts, operators, finance roles, etc., who use Agents for SQL or visualization and need stable HTML/JSON (and optional PDF) report generation.
  • Teams wanting unified usage of tables, matrices, slicers, and navigation components in reports, plus reusable preset templates across multiple industries.

Limitations and Notes

  • Full capabilities rely on a Python environment; without dependencies, it serves only as documentation-level assistance.
  • Chain examples with sql-master and sql-dataviz are provided in SKILL.md; related Skills must be installed separately, and this Skill does not replace querying or charting.
  • PDF and some statistical capabilities require additional packaging; performance tables (e.g., “5 charts approx. 500ms”) come from Skill self-descriptions and depend on data volume and runtime environment.
  • The contact email and GitHub link at the end of SKILL.md are placeholder examples and should not be treated as official support channels.

Conclusion

SQL Report Generator consolidates the layout, components, statistical insights, and export “post-query/chart” steps into a reusable workflow, forming an optional three-stage pipeline with sql-master and sql-dataviz. To obtain the package and updates from SkillHub, use the installation commands above and visit the Skill page at https://skillhub.cn/skills/sql-report-generator; the API address from the lead is https://api.skillhub.cn/user_64e5b706/sql-report-generator.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye