text-to-sql-query for Openclaw

A natural language interface for direct SQL generation and execution against retail databases.

jackyujun
v1.0.0
Mar 27, 2026
1
1k
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install text-to-sql-query

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install text-to-sql-query using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is text-to-sql-query?

The text-to-sql-query skill is a specialized tool designed to bridge the gap between natural language questions and complex retail data. By analyzing the database schema of retail fact and dimension tables, it translates user intent into precise SQL queries. Unlike many traditional business intelligence tools, this skill does not rely on a semantic layer or metrics platform; it operates directly on the database schema to provide real-time results.

This skill is particularly powerful for retail environments, as it is pre-configured to understand relationships between orders, inventory, products, shops, and VIP customers. It leverages high-end models like Claude Opus or GPT-4o for nuanced implementation, while maintaining strict template adherence for standard models, ensuring reliable performance across different AI architectures.

text-to-sql-query Use Cases

  • Retail sales performance analysis for specific time periods or channels.
  • Inventory snapshot tracking across different warehouses and shops.
  • VIP customer behavior analysis and ranking based on purchase history.
  • Product launch performance tracking and brand-level sales comparisons.
  • Quick generation of SQL templates for daily, monthly, or year-over-year growth reports.

How text-to-sql-query Works

  1. The skill receives a natural language query from the user regarding retail data.
  2. It performs a semantic analysis to identify metrics (e.g., sales), dimensions (e.g., channel), and timeframes.
  3. Based on the identified intent, it selects the appropriate fact and dimension tables for JOIN operations.
  4. A valid SQL SELECT statement is generated following StarRocks/MySQL syntax.
  5. The skill executes the query via a POST request to the Gateway JDBC SQL interface.
  6. Results are returned as a Markdown table for clear visualization and further analysis.

text-to-sql-query Setup

To use this skill, ensure the $CAN_API_KEY environment variable is set. The skill interacts with the Aloudata Gateway.

# Example of setting the environment variable
export CAN_API_KEY='your_api_key_here'

# Direct query via curl
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": "SELECT * FROM fact_orders LIMIT 10"}'

text-to-sql-query Data Schema & Taxonomy

The skill utilizes a Star Schema architecture consisting of 3 Fact tables and 3 Dimension tables:

Table Name Type Description
fact_orders Fact Transactional order details including amounts and quantities.
fact_inventory Fact Daily inventory snapshots per SKU and warehouse.
fact_product_launch Fact Records of product launches at specific stores.
dim_product Dimension SKU-level attributes, categories, and pricing.
dim_shop Dimension Store locations, channels, and management info.
dim_vip Dimension Member profiles, levels, and registration dates.

Primary JOIN Keys:

  • sku: Links all fact tables to dim_product.
  • tr_shop_code: Links fact tables to dim_shop.
  • vip_id: Links fact_orders to dim_vip.

text-to-sql-query Advanced Features

  • Dual Execution Modes: Uses "Principle Mode" for advanced models and "Template Mode" for standard models to ensure SQL accuracy.
  • Automated Time Handling: Converts relative terms like "last month" or "yesterday" into precise SQL date functions.
  • Intelligent Disambiguation: Rules-based logic to distinguish between "Total" vs "Individual" metrics and "YoY" vs "MoM" growth.
  • Security Guardrails: Strictly enforces SELECT-only permissions and white-listed tables to prevent unauthorized data manipulation.
  • Window Function Support: Capable of performing complex calculations like global proportions and ranking directly in the query.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*