Xpersona
A

Aloudata CAN SKILLS - text-to-sql-query

CLAWHUB · Unverified

直接通过 Text-to-SQL 方式查询零售数据库。根据用户自然语言描述,生成 SQL 查询语句并执行。 本 Skill 不依赖语义层或指标平台,而是直接基于数据库 schema 生成 SQL。 触发场景:用户需要查询零售数据、生成 SQL 查询、分析销售/客户/商品数据时使用。 Skill: Aloudata CAN SKILLS - text-to-sql-query Owner: jackyujun Summary: 直接通过 Text-to-SQL 方式查询零售数据库。根据用户自然语言描述,生成 SQL 查询语句并执行。 本 Skill 不依赖语义层或指标平台,而是直接基于数据库 schema 生成 SQL。 触发场景:用户需要查询零售数据、生成 SQL 查询、分析销售/客户/商品数据时使用。 Tags: latest:1.0.0 Version history: v1.0.0 | 2026-03-27T09:47:31.988Z | user text-to-sql-query 1.0.0 - Initial release of the Text-to-SQL 数据查询 Skill for querying retail databases via natural language. - Su

62
Rank
84
Safety
1.0k
Downloads

About

What it does, and when to use it.

Capability contract not published. No trust telemetry is available yet. 1K downloads reported by the source. Last updated 10/11/2026.

Avoid when

  • Contract metadata is missing or unavailable for deterministic execution.

Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing

Install and run

Setup complexity: low.

clawhub skill install s172qm3yezbbjev7q8rsxxbd1s83he2f:text-to-sql-query
  1. Setup complexity is LOW. This package is likely designed for quick installation with minimal external side-effects.
  2. Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.

Contract: missing

curl -s "https://www.xpersona.co/api/v1/agents/clawhub-jackyujun-text-to-sql-query/snapshot"

Run-check

$0.02 USD

1 measured facts are behind this paywall: success rate and latency, uptime and estimated cost, when not to use it, how to call it, benchmark scores.

Agents pay $0.02 in USDC. A card payment is $0.50, the smallest a card allows.

Documentation

CLAWHUB

25,908 characters of source documentation, loaded on request.

Extracted files

3 files captured from the source.

SKILL.md

---
name: text-to-sql-query
description: |
  直接通过 Text-to-SQL 方式查询零售数据库。根据用户自然语言描述,生成 SQL 查询语句并执行。
  本 Skill 不依赖语义层或指标平台,而是直接基于数据库 schema 生成 SQL。
  触发场景:用户需要查询零售数据、生成 SQL 查询、分析销售/客户/商品数据时使用。
---

# Text-to-SQL 数据查询 Skill

根据用户自然语言描述,直接生成 SQL 查询语句,通过 Gateway JDBC SQL 直查接口在零售数据库上执行并返回结果。

## 执行模式

- **强模型**(Claude Opus/Sonnet, GPT-4o/5):遵循"原则"段落,自行决定实现细节
- **标准模型**(Qwen, DeepSeek, Llama):严格按"模板"段落执行,使用提供的代码块,不要自行改写

> 如果你不确定自己属于哪个类别,请按"标准模型"模式执行。

---

## 0. 查询接口信息

通过 Gateway JDBC SQL 直查接口执行 SQL 查询。API Key 通过环境变量 `$CAN_API_KEY` 注入,禁止在 Skill 文件中硬编码。

### 0.1 接口地址

```
POST https://gateway.can.aloudata.com/api/jdbc/query
Content-Type: application/json
X-API-Key: $CAN_API_KEY
```

请求体:
```json
{"sql": "SELECT ... FROM table_name WHERE ... LIMIT N"}
```

### 0.2 执行方式

**方式一:curl(推荐,适合 Bash 环境)**
```bash
curl --noproxy '*' -s \
  -H "X-API-Key: $CAN_API_KEY" \
  -H "Content-Type: application/json" \
  -X POST "https://gateway.can.aloudata.com/api/jdbc/query" \
  -d '{"sql": "YOUR SQL HERE"}'
```

**方式二:Python requests**
```python
import os, requests

response = requests.post(
    "https://gateway.can.aloudata.com/api/jdbc/query",
    headers={
        "X-API-Key": os.environ["CAN_API_KEY"],
        "Content-Type": "application/json"
    },
    json={"sql": "YOUR SQL HERE"}
)
print(response.text)  # 返回 Markdown 表格(纯文本)
```

**多行 SQL 示例(curl heredoc)**:
```bash
curl --noproxy '*' -s \
  -H "X-API-Key: $CAN_API_KEY" \
  -H "Content-Type: application/json" \
  -X POST "https://gateway.can.aloudata.com/api/jdbc/query" \
  -d @- <<'EOF'
{"sql": "SELECT o.dt, o.order_number, p.style_name, s.shop_name, o.retail_amount FROM fact_orders o JOIN dim_product p ON o.sku = p.sku JOIN dim_shop s ON o.shop_code = s.tr_shop_code WHERE o.dt >= '2024-01-01' ORDER BY o.dt DESC LIMIT 20"}
EOF
```

### 0.3 返回格式

**成功时**返回 **Markdown 表格**(纯文本,非 JSON):
```
| sku | style_name | color_name | tag_price |
| --- | --- | --- | --- |
| SKU1000211 | 泡泡袖衬衫春秋款 | 白色 | 118.8600 |
| SKU1000222 | 背带裤明星同款 | 灰色 | 439.1300 |
2 row(s) returned.
```

**错误时**返回纯文本错误信息:
- `SQL validation error: Table not allowed: xxx` — 查询了白名单以外的表
- `SQL validation error: Only SELECT statements are allowed` — 非 SELECT 语句
- `Query error: Query timed out after 30 seconds` — 查询超时

### 0.4 安全限制

- **只允许 SELECT**:INSERT/UPDATE/DELETE/DROP 等写操作会被拒绝
- **表白名单**:只允许查询 §1.1 中的 6 张表(dim_product, dim_vip, dim_shop, fact_orders, fact_inventory, fact_product_launch),查询其他表会返回 `Table not allowed` 错误
- **禁止多语句**:不能用分号拼接多条 SQL
- **自动加 LIMIT**:未指定 LIMIT 时服务端自动追加 LIMIT 1000
- **查询超时**:默认 30 秒超时
- **UNION 默认禁止**

---

## 1. 数据库 Schema

### 1.1 表结构总览

本数据库采用**星型模型**,包含 3 张事实表 + 3 张维度表。

| 表名 | 类型 | 说明 |
|------|------|------|
| fact_orders | 事实表 | 订单明细,每行一笔订单行项目 |
| fact_inventory | 事实表 | 库存快照,每行一个 SKU 在某门店/仓库的库存状态 |
| fact_product_launch | 事实表 | 商品上市记录,每行一个 SKU 在某门店的上市信息 |
| dim_product | 维度表 | 商品维度,SKU 级商品属性 |
| dim_shop | 维度表 | 店铺维度,门店属性及地理信息 |
| dim_vip | 维度表 | 会员维度,会员属性信息 |

### 1.2 事实表字段

#### fact_orders(订单事实表)
| 字段名 | 类型 | 说明 |

_meta.json

{
  "ownerId": "kn7a65qw8tzzh15x5fhs1yx85n835khy",
  "slug": "text-to-sql-query",
  "version": "1.0.0",
  "publishedAt": 1774604851988
}

skill-card.md

## Description:

Generates and executes SQL queries against a retail database from natural-language requests, using the provided schema directly instead of a semantic layer.

This skill is ready for commercial/non-commercial use.

## Publisher:

[jackyujun](https://clawhub.ai/user/jackyujun)

### License/Terms of Use:

MIT-0

## Use Case:

Business analysts and retail data users use this skill to ask natural-language questions, generate SQL for sales, inventory, customer, store, and product analyses, and execute the query through the configured Gateway JDBC interface.

### Deployment Geography for Use:

Global

## Known Risks and Mitigations:

Risk: Broad database query access can expose member, employee, address, order-level, or other person-level records.

Mitigation: Install only where users are authorized to query the retail database, prefer a restricted gateway role or approved analytics views, audit queries, and require redaction or approval before returning person-level records.

Risk: The artifact recommends bypassing proxies for Gateway API requests.

Mitigation: Remove the global proxy bypass and route requests through the environment's approved network controls.

Risk: Generated SQL can use an incorrect metric definition because the skill directly maps natural language to schema fields without a semantic layer.

Mitigation: Require users or reviewers to confirm ambiguous metric definitions, especially for sales amount, average order value, discount, return rate, and other derived metrics.

## Reference(s):

- [ClawHub skill page](https://clawhub.ai/jackyujun/skills/text-to-sql-query)
- [Gateway JDBC SQL query endpoint](https://gateway.can.aloudata.com/api/jdbc/query)

## Skill Output:

**Output Type(s):** [text, markdown, code, shell commands, guidance]

**Output Format:** [Markdown with SQL, curl, and Python code blocks; query results are returned as Markdown tables or plain-text errors.]

**Output Parameters:** [1D]

**Other Properties Related to Output:** [Requires CAN_API_KEY and access to the configured Gateway JDBC endpoint; queries are intended to be SELECT-only against the documented whitelist tables.]

## Skill Version(s):

1.0.0 (source: server release evidence)

## Ethical Considerations:

Users should evaluate whether this skill is appropriate for their environment, review any generated or modified files before relying on them, and apply their organization's safety, security, and compliance requirements before deployment.

Sponsored

Ads related to Aloudata CAN SKILLS - text-to-sql-query and adjacent AI workflows.