Token导航 LogoToken导航

Agent Skill · 效率

text2sql(text2sql 数据库)

text2sql 用于处理数据库查询、表结构、迁移和数据维护任务,适合在 OpenClaw 中需要分析 schema、编写 SQL 或排查数据问题时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

text2sql 是效率类 Agent Skill,可用宿主为 OpenClaw,通过ClawHub获取,权限为需要联网;许可证为 MIT-0,第三方扫描有提醒项,按安装量在效率类的 21,003 个 Skill 里排第 17,579。

总安装 2,566周安装 108GitHub Stars 1下载 899核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT-0
版本
1.0.0

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:text2sql(text2sql 数据库)
来源仓库:https://github.com/zionwa/text2sql
安装命令:
openclaw skills install text2sql
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install text2sql

这个 Skill 是做什么的

效率类 Skill 把重复的整理、汇总、转换工作交给助手完成,减少手工复制粘贴。

用于处理数据库查询、表结构、迁移和数据维护任务,适合在 OpenClaw 中需要分析 schema、编写 SQL 或排查数据问题时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

安装命令:openclaw skills install text2sql 来源仓库:https://github.com/zionwa/text2sql

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 OpenClaw;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 openclaw skills install text2sql;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

text2sql 怎么安装?

在终端执行 openclaw skills install text2sql。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

text2sql 支持哪些 AI 工具?

公开资料标注支持 OpenClaw。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

text2sql 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

text2sql 是免费的吗?

来源标注的许可证是 MIT-0。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

text2sql 用的人多吗?

公开数据是累计安装 2,566 次,近一周安装 108 次,下载 899 次,GitHub 1 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

text2sql 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 专注 OpenClaw 一种宿主,触发方式和使用习惯不用来回切换。
  • 许可证明确为 MIT-0,商用和分发边界好判断。

先想清楚的地方

  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 OpenClaw,想直接扩展它能力的人。
  • 需要处理效率类任务、又不想每次都手写提示词的人。

不太适合

  • 需要厂商级技术支持和 SLA 的生产系统。

效率类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
github

GitHub 代码协作 · OpenClaw

7,632,918545需要联网MIT-0通过
nano-pdf

Nano PDF 文档 · OpenClaw

4,249,476231需要联网MIT-0通过
auto-updater

自动更新程序 · OpenClaw

2,964,063386操作浏览器MIT-0通过
video-frames

视频帧 · OpenClaw

2,621,304112需要联网MIT-0通过
gemini

Gemini 助手 · OpenClaw

2,547,39648需要联网MIT-0有提醒
text2sql

text2sql 数据库 · 本页

2,5661需要联网MIT-0有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

name
text-to-sql
description
Support generating SQL queries through natural language; use when users need to configure Text-to-SQL database, manage data topics, or generate SQL with natural language questions
dependency
python

Text-to-SQL Intelligent Query Skill

Task Objectives

  • This Skill is used for: Generating SQL query statements through natural language, supporting multi-topic database configuration and table structure management
  • Capabilities include: Database configuration, topic management, table structure reading, natural language to SQL
  • Trigger conditions: User needs to configure Text-to-SQL database, create data topics, select data tables, or generate SQL with natural language questions

Prerequisites

Dependency Description

Required packages and versions for scripts:

pyyaml>=6.0
sqlalchemy>=2.0.0

API Service Description

This Skill generates SQL through the HTTP API /api/sql_for_skill/ endpoint:

  • Default API address: https://asksql.ucap.com.cn/
  • Service needs to be started before calling
  • Supports custom API address (via --api-url parameter)

API Interface Specification:

  • Endpoint path: POST /api/sql_for_skill/
  • Request format: multipart/form-data
  • Request parameters:

- question: User's natural language question (string) - yaml_file: YAML configuration file (uploaded as file)

  • Response format: JSON array
  • Response example:
  [
    {
      "STATUS": "ok",
      "MESSAGE": "",
      "SQL": "SELECT SUM(total_amount) AS total_sales FROM orders WHERE YEAR(signing_date) = 2026",
      "SQL_NO_PERM": "SELECT SUM(total_amount) AS total_sales FROM orders WHERE YEAR(signing_date) = 2026",
      "QUESTION": "This year's total sales"
    }
  ]
  • Return value: Extract the SQL field from the first element of the response array

Data Configuration Methods

Two Configuration Methods Explained

When the agent guides users through data configuration, it must clearly explain the following two methods:

Method 1: Database URL Configuration (Highly Recommended)

  • Read table structure directly through database connection
  • Real-time data synchronization, ensuring accuracy
  • Supports complete database semantic understanding

Method 2: Excel File Configuration

  • Suitable for scenarios where direct database connection is not possible
  • Configure through Excel file with specific format requirements

Excel File Format (Must Strictly Follow):

┌─────────────────────────────────────────────────────────────────┐
│ Excel File: products.xlsx                                       │
├─────────────────────────────────────────────────────────────────┤
│ Sheet: orders (Sheet name = Table name)                         │
├──────────┬──────────┬────────────┬───────────┬─────────────────┤
│ order_id │ customer │ order_date │  amount   │ status          │
│ (Column) │ (Column) │  (Column)  │ (Column)  │ (Column)        │
├──────────┼──────────┼────────────┼───────────┼─────────────────┤
│   1001   │  John    │ 2024-01-15 │  1500.00  │ completed       │
│   1002   │  Mary    │ 2024-01-16 │  2300.50  │ pending         │
│   ...    │  ...     │    ...     │    ...    │ ...             │
└──────────┴──────────┴────────────┴───────────┴─────────────────┘
         ↑ First row = Column names (field names)
         ↑ Data starts from second row

Format Requirements:

  1. File naming: Excel filename must match database name (e.g., products.xlsx for products database)
  2. Sheet naming: Each sheet name must exactly match the table name (e.g., orders sheet for orders table)
  3. First row: Must contain column names (field names), cannot be empty
  4. Second row onwards: Actual data rows (optional, used for understanding data types)

The agent should clearly recommend users to prioritize the database URL configuration method. Only use the Excel file method when users cannot provide a database connection.

Method 1: Database URL Configuration

Configuration Steps
  1. Guide the user to provide database connection information
  2. Call the configuration script to save database information:
python scripts/config_db.py --db-url <database URL> --db-password <password> --config-file ./output/text-to-sql-config.json

This script saves the configuration to ./output/text-to-sql-config.json file.

Database URL Format
database_type://username:password@host:port/database_name

Examples:

  • MySQL: mysql://root:password@localhost:3306/mydb (will auto-convert to use pymysql driver)
  • MySQL with explicit driver: mysql+pymysql://root:password@localhost:3306/mydb
  • SQL Server: mssql://sa:password@localhost:1433/mydb

Note: For MySQL connections, the system automatically converts mysql:// to mysql+pymysql:// for better compatibility. You can also explicitly specify the driver.

Reading Table Structure

After configuration, use the following command to read table structure:

python scripts/read_tables.py --config-file ./output/text-to-sql-config.json

Method 2: Excel File Configuration

Applicable Scenarios

When users cannot provide a database connection, the Excel file method can be used for configuration.

Configuration Steps
  1. Guide the user to provide the Excel file path
  2. Remind user to follow the Excel file format requirements described above
  3. After the user provides the file, no parsing operation is needed, directly call the read_tables.py script:
python scripts/read_tables.py --excel-file <Excel file path>

Example:

python scripts/read_tables.py --excel-file data_file.xlsx
  • Parameter description:

- --excel-file: Complete path to the Excel file

Operation Steps

Step 0: Configuration Check (Must Execute on First Call)

Important: The agent must check the configuration status before performing any operation

The agent needs to check whether yaml configuration files exist in the ./output/ directory:

Check Method:

# Check if .yaml files exist in ./output/ directory
ls ./output/*.yaml 2>/dev/null

Check Result Handling:

Scenario A: yaml configuration files exist

  • Indicates user has completed configuration in advance
  • Agent skips all configuration steps (Step 1 and Step 2)
  • Proceed directly to Step 3 (Query with natural language)
  • Agent informs user: "Detected existing topic configuration, you can ask questions directly."
  • List configured topic names for user reference

Scenario B: No yaml configuration files

  • Indicates user has not completed configuration
  • Agent proceeds to execute Step 1 (Database Configuration) and Step 2 (Topic Setup)
  • Guide user through the standard configuration process

Standard Configuration Process

Step 1: Database Configuration

The agent must clearly explain the two configuration methods:

  1. Method 1: Database URL Configuration (Highly Recommended)

- Read table structure directly through database connection - Real-time data synchronization, ensuring accuracy - Supports complete database semantic understanding

  1. Method 2: Excel File Configuration

- Suitable for scenarios where direct database connection is not possible - Configure through Excel file schema description

The agent should clearly recommend users to prioritize the database URL configuration method.

If user chooses database URL configuration: Guide user to provide database URL and password, save to local configuration file:

python scripts/config_db.py --db-url <database URL> --db-password <password>

This script saves the configuration to text-to-sql-config.json file.

If user chooses Excel file configuration:

  1. Guide user to provide Excel file path
  2. Remind user to follow the Excel File Format requirements described in the "Two Configuration Methods Explained" section above
  3. After user provides file, no parsing operation needed, directly call:
python scripts/read_tables.py --excel-file <Excel file path>
Step 2: Topic Setup

Important: The agent must mandatorily guide users to set up topics, table selection step cannot be skipped

The agent should guide users through the following process:

2.1 Clearly inform user that topic setup is mandatory

  • Agent clearly states: "Topic setup is a mandatory step, it will help you get more accurate SQL generation results and better query performance."
  • Explain benefits of setting up topics: more accurate SQL generation, faster query speed, better business semantic understanding

2.2 Execute topic setup process

  • Agent must guide user to create topics and select tables, table selection step cannot be skipped
  • Multiple topics can be created
  • Execution steps:

1. Call script to read all table structures and generate knowledge

     # Method 1: Use database connection (recommended)
     python scripts/read_tables.py --config-file ./output/text-to-sql-config.json --output-dir ./output

     # Method 2: Use Excel file
     python scripts/read_tables.py --excel-file data_file.xlsx

This script generates table_info.json (table name list) and column_info.json (table structure information) files. 2. Agent reads table list from table_info.json file, displays all tables to user completely, provides clear table descriptions 3. Key emphasis: Table selection is a critical step in topic creation, directly affects SQL generation accuracy and query effectiveness, must be autonomously selected by user based on actual business needs 4. Ask user: "Please tell me the topic name you want to create (e.g., sales topic, human resources topic)" 5. Agent is strictly prohibited from selecting tables for topics itself, must require user to explicitly specify needed tables 6. Agent can provide brief table descriptions and recommendations, but final selection must be completely left to user 7. Generate topic configuration file

     python scripts/generate_yaml.py --topic-name <topic name> --tables <table list comma-separated> --output-path ./output/

8. Ask user: "Do you want to continue creating other topics?" 9. User can repeat to create multiple topics (no need to re-read table structure, use existing ./output/column_info.json directly)

2.3 Agent Guidance Recommendations

  • Agent is prohibited from making assumptions or guessing user intent
  • Agent must mandatorily guide user to set up topics, cannot allow skipping
  • Agent is strictly prohibited from setting topics or selecting tables for topics itself, must display all table lists to user after reading table structure, let user completely autonomously select relevant tables based on actual business needs
  • Agent can provide brief table descriptions and recommendations, but final selection must be completely left to user
  • Key emphasis: Table selection step cannot be skipped, this is a key link to ensure topic configuration accuracy
  • Prioritize recommending database connection method to users, only use Excel file method when user cannot provide database connection
Step 3: Query with Natural Language (Includes Topic Selection Logic)

Important: Step 3 can be executed directly (when Step 0 detects existing configuration)

After configuration is complete (or when existing configuration is detected), users can ask questions in natural language, the agent needs to select topic and generate SQL according to the following logic:

3.1 Topic Selection Logic

Scenario: One or more topics exist (user has completed topic setup)

Case A: User question explicitly mentions topic

  • Agent identifies topic keywords in user question (e.g., "sales", "human resources", "inventory", etc.)
  • Matches corresponding <topic name>.yaml file in ./output/ directory
  • If match is successful, directly use that yaml file to call script
  • If match fails, prompt user that topic does not exist and list available topics

Case B: User question does not explicitly mention topic

  • Agent analyzes question content, selects most relevant topic from all topics
  • Agent informs user: "Based on your question, I suggest using [topic name] topic, continue?"
  • If user confirms, use that topic; if user declines, list all topics for user to select
3.2 Call SQL Generation Script

After determining topic, call API to generate SQL:

python scripts/query_sql.py --api-url https://asksql.ucap.com.cn/ --question "user question" --config ./output/<topic name>.yaml

The script calls the API's /api/sql_for_skill/ endpoint and returns the generated SQL statement.

Optional Branches

  • When user wants to modify topic configuration: Re-call generate_yaml.py to overwrite original configuration file
  • When user wants to reconfigure database: Re-call config_db.py to overwrite configuration file
  • When user wants to view configured topics: Agent lists yaml files in ./output/ directory
  • When user question is ambiguous and cannot determine topic: Agent actively asks user or lists all topics for selection
  • When API service is not at default address: Use --api-url parameter to specify custom API address

Resource Index

Required Scripts

Output Files

All generated files are stored in ./output/ directory:

  • table_info.json - Table name list
  • column_info.json - Table structure information
  • <topic_name>.yaml - Topic configuration files
  • references/open_semantic_interchange_description.md - YAML file format specification and field definitions (refer to this document when users ask about YAML format, field meanings, or configuration details)

Notes

  • All scripts are pure functional tools without interaction logic, all inputs are passed through parameters
  • Database URL and password are saved in local configuration file ./output/text-to-sql-config.json
  • Topic configuration files are stored in yaml format for easy version management and viewing
  • Only query_sql.py calls API, other scripts are all executed locally
  • If database connection fails, check if URL and password are correct
  • If API service connection fails, check if service is started and address is correct
  • Prioritize database connection method, only use Excel file method when database connection cannot be provided
  • When users ask about YAML file format, field definitions, or configuration details, refer to the open_semantic_interchange_description.md document which contains complete specification of the semantic model YAML structure

Usage Examples

Example 0: Detected Existing Configuration (Direct Query)

  1. User: "Query last month's total sales"
  2. Agent: Check ./output/ directory
  3. Agent: Detect existing topic configuration files
  4. Agent: "Detected existing topic configuration, you can ask questions directly."
  5. Agent: Identify topic relevant to the question, use corresponding topic configuration file
  6. Agent: Call query_sql.py to generate SQL

Example 1: Intelligently Guide User to Set Up Topic (Recommended Process)

  1. User: "Help me configure Text-to-SQL"
  2. Agent: Check ./output/ directory
  3. Agent: No yaml configuration files found, need to execute configuration process
  4. Agent: "Please provide database URL and password"
  5. User: "Database URL is URL"
  6. Agent: Call config_db.py to save configuration
  7. Agent: "Topic setup is a mandatory step, it will help you get more accurate SQL generation results and better query performance."
  8. Agent: Call read_tables.py --config-file ./output/text-to-sql-config.json --output-dir ./output to read all tables
  9. Agent: "There are multiple tables in the database, what topic do you want to create?"
  10. User: "Create a topic"
  11. Agent: "Please select tables to include in this topic from the database tables"
  12. User: "Select relevant tables"
  13. Agent: Call generate_yaml.py to generate topic configuration file
  14. Agent: "Do you want to continue creating other topics?"
  15. User: "No need"
  16. User: "Query the top 10 products with highest sales last month"
  17. Agent: Identify topic relevant to the question, use corresponding topic configuration file to call query_sql.py to generate SQL

Example 2: Configure with Excel File

  1. User: "Help me configure Text-to-SQL, but I don't have a database"
  2. Agent: Check ./output/ directory
  3. Agent: No yaml configuration files found, need to execute configuration process
  4. Agent: "Okay, you can use the Excel file method for configuration. Please provide an Excel file with format requirements: each sheet corresponds to a table name, first row is column names"
  5. User: "Provide Excel file path"
  6. Agent: Call read_tables.py --excel-file data_file.xlsx to read Excel data
  7. Agent: "Topic setup is a mandatory step..."
  8. Follow same process as Example 1

Example 3: Set Up Multiple Topics

  1. User: "Help me configure Text-to-SQL"
  2. Agent: Check ./output/ directory
  3. Agent: No yaml configuration files found, need to execute configuration process
  4. Agent: "Please provide database URL and password"
  5. User: "Database URL is URL"
  6. Agent: Call config_db.py to save configuration
  7. Agent: "Topic setup is a mandatory step, it will help you get more accurate SQL generation results and better query performance."
  8. Agent: Call read_tables.py --config-file text-to-sql-config.json to read all tables
  9. Agent: "There are multiple tables in the database, what topic do you want to create?"
  10. User: "Create first topic"
  11. Agent: "Please select tables to include in this topic from the database tables"
  12. User: "Select relevant tables"
  13. Agent: Call generate_yaml.py to generate topic configuration file
  14. Agent: "Do you want to continue creating other topics?"
  15. User: "Create another topic"
  16. Agent: "Please select tables to include in this topic from the database tables"
  17. User: "Select relevant tables"
  18. Agent: Call generate_yaml.py to generate topic configuration file
  19. Agent: "Do you want to continue creating other topics?"
  20. User: "No need"
  21. User: "Query average salary of technical department"
  22. Agent: Identify topic relevant to the question, determine most relevant topic
  23. Agent: "Based on your question, I suggest using relevant topic, continue?"
  24. User: "Yes"
  25. Agent: Call query_sql.py using corresponding topic configuration file to generate SQL

Example 4: User Explicitly Specifies Topic

  1. User configured multiple topics
  2. User: "Use a specific topic to query total orders in 2024"
  3. Agent: Check ./output/ directory (existing configuration)
  4. Agent: Identify topic explicitly specified by user, directly use corresponding topic configuration file
  5. Agent: Call query_sql.py to generate SQL

Example 5: Custom API Address

  1. User: "My Text-to-SQL service is deployed at http://127.0.1.100:8080"
  2. Agent: All query_sql.py calls use --api-url http://127.0.1.101:8080 parameter
  3. User: "Query sales data"
  4. Agent: Call query_sql.py --api-url http://127.0.1.101:8080 --config using corresponding topic configuration file to generate SQL

平台分布

OpenClaw

70.55%
按下载量换算634

安全审计

VirusTotal

可疑

ClawScan

可疑

Static analysis

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills