AI NL2SQL

# NL2SQL · Natural Language to SQL

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "AI NL2SQL" with this command: npx skills add ai-nl2sql

NL2SQL · Natural Language to SQL

Upload CSV/Excel files → Ask questions in plain English → AI generates and executes SQL → Returns readable results + optional charts


Trigger Phrases

nl2sql text to sql natural language sql ask database csv query excel sql 数据查询 自然语言查数


Usage

Command Line

# Basic query
python -m scripts.main "Which product has the highest sales?" -f data/sales.csv

# Generate chart
python -m scripts.main "Monthly sales trend" -f data/sales.csv --chart line

# Export results
python -m scripts.main "Top 10 customers" -f data/customers.csv --format csv -o result.csv

Python API

from scripts import NL2SQLService, QueryRequest

service = NL2SQLService(api_key="your-api-key")

request = QueryRequest(
    question="Which product has the highest sales?",
    files=["data/sales.csv"],
    chart_type="bar",
    explain=True
)

response = service.query(request)

if response.success:
    print(f"SQL: {response.sql}")
    print(f"Results: {response.data}")

Parameters

QueryRequest

ParameterTypeRequiredDescription
questionstrYesNatural language question
filesList[str]YesFile paths (CSV/Excel)
chart_typestrNoChart type: bar/line/pie/scatter/area/histogram
explainboolNoWhether to explain the SQL
output_formatstrNoOutput format: markdown/json/csv (default: markdown)

QueryResponse

FieldTypeDescription
successboolWhether the query succeeded
sqlstrGenerated SQL
explanationstrSQL explanation
row_countintNumber of result rows
columnsList[str]Column names
dataList[dict]Result data
chart_base64strChart image as base64
errorstrError message if failed

Supported Formats

FormatExtensionsNotes
CSV.csvUTF-8/GBK auto-detected
Excel.xlsx, .xlsMulti-sheet supported

Tech Stack

  • Parsing: pandas, openpyxl
  • AI: OpenAI GPT-4 (via user-provided API key)
  • Charts: matplotlib
  • Execution: pandasql (SQL on DataFrame, fully offline sandbox)

Tiered Features

FeatureFREEPRO
Queries3 per sessionUnlimited
File size5 MB max200 MB max
JOIN supportNoYes
Chart typesbar, line, pieAll types
Export formatsCSVCSV, Excel, PDF
AI SQL generationNo (rule-based)Yes (GPT-4)

Billing

$0.01 USDT per call — billed via SkillPay at https://skillpay.me/ai-nl2sql

Privacy Note: Your Feishu User ID (Open ID) may be transmitted to skillpay.me for billing purposes only.

| Price | $0 (FREE tier) | $0.01 / call (PRO tier) |

For paid use, visit https://skillpay.me/ai-nl2sql


Required Environment Variables

VariableDescription
SKILL_BILLING_API_KEYSkillPay Builder API Key (from skillpay.me)
SKILL_BILLING_SKILL_IDSkill ID on SkillPay (default: ai-nl2sql)

API Key Format

Any non-empty string works as an API key. The tier is determined automatically:

  • No API key → FREE tier (rule-based SQL only)
  • Any API key → PRO tier (GPT-4 powered)

Slug

ai-nl2sql


Security Notes

  • SQL Safety: All AI-generated SQL passes through an SQLValidator that blocks all non-SELECT queries (DROP, DELETE, INSERT, UPDATE, CREATE, EXEC, GRANT, etc.). Only read-only queries are permitted.
  • Data Isolation: SQL execution runs entirely in a local pandas DataFrame sandbox. No real database connection is made. No data leaves the user's environment.
  • External Data Transmission: Your Feishu User ID (Open ID) is transmitted to skillpay.me exclusively for billing purposes. See ## Billing for details.

Notes

  1. All SQL execution runs in a local pandas DataFrame sandbox — no real database connection
  2. AI SQL generation requires a valid OpenAI API key provided by the user
  3. Network errors gracefully degrade to FREE tier

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Img2img

Generate images from text descriptions using DALL-E 3 while adhering to usage policies and avoiding realistic human faces.

Registry SourceRecently Updated
General

Habitat-GS-Navigator

Navigate and interact with photo-realistic 3DGS environments via the Habitat-GS Bridge. Use when: user asks to explore a 3D scene, perform embodied navigatio...

Registry SourceRecently Updated
General

Memory Palace

持久化记忆管理。Use when: 用户告诉你个人信息/偏好/习惯、需要记住项目状态/技术决策、完成任务后有可复用经验、用户说"记住""别忘了""下次注意"、需要回忆之前的对话内容。支持语义搜索和时间推理。

Registry SourceRecently Updated
General

Podcast Transcript Mining Authority Positioning

Extract guest appearances, speaking topics, and soundbites from podcast transcripts to build authority portfolios and generate podcast pitch templates. Use w...

Registry SourceRecently Updated