SQL Buddy for Openclaw

An AI-powered database companion that translates natural language into secure, optimized SQL queries and provides intelligent database schema insights.

harrylabsj
v1.0.0
Jun 16, 2026
0
418
0

Install & Download

1. ClawHub CLI

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

npx clawhub@latest install sql-buddy

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 sql-buddy 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 SQL Buddy?

SQL Buddy is a powerful database assistant designed to bridge the gap between human intent and complex database queries. By integrating seamlessly with your databases, it lets you express questions in natural language (Chinese or English) and automatically generates, optimizes, and safely executes the corresponding SQL queries. As part of the growing ecosystem of Openclaw Skills, it provides a developer-friendly interface to explore tables, inspect execution plans, and run read-only queries securely out of the box.

Whether you are interacting with SQLite, PostgreSQL, MySQL, or SQL Server, SQL Buddy prioritizes security by defaulting to a read-only execution mode. Sensitive schema details like passwords are never logged, and critical data like password hashes are masked automatically, giving you the power of AI database analysis without exposing sensitive operational data.

SQL Buddy Use Cases

  • Rapid Data Exploration: Query transactional tables using natural language to quickly find user metrics, registration trends, or sales breakdowns without writing SQL from scratch.
  • Database Schema Discovery: Instantly map out tables, columns, data types, primary keys, and foreign key relationships on unfamiliar databases.
  • SQL Performance Optimization: Analyze slow-running queries with auto-generated EXPLAIN plans and index suggestions to resolve database bottlenecks.
  • Read-Only Safe Analytics: Empower product managers or data analysts to query production or staging databases safely without accidental write-operations.
  • AI-Powered Result Interpretation: Receive plain-text business insights and anomaly reports alongside raw query results to make sense of complex metrics instantly.

How SQL Buddy Works

  1. Input Parsing: The user provides a natural language query or direct SQL along with database connection credentials.
  2. Schema Discovery & Masking: The skill connects to the database, extracts schema context, and masks sensitive column names to protect schema privacy.
  3. Query Generation: The parser uses few-shot prompting to accurately translate the user's intent into syntactically valid SQL tailored to the specific database dialect.
  4. Validation & Security Check: The generated SQL is scanned for safety; writing operations (DDL/DML) are blocked unless the --allow-write flag is explicitly provided.
  5. Execution & Optimization: Optional EXPLAIN plan analysis generates performance tips, after which the query is safely executed.
  6. Formatting & Insights: Query results are returned in the requested format (table, CSV, JSON, Markdown) along with AI-generated qualitative insights explaining the data.

SQL Buddy Setup

Installation

Install the SQL Buddy skill directly via the command line:

clawhub install sql-buddy

Running Your First Query

You can connect to a local SQLite database and query it using natural language:

clawhub run sql-buddy --query "Show me all active users" --connection sqlite:///./app.db --execute

Connection Configuration

Configure your connection string based on your database system:

  • SQLite: sqlite:///path/to/database.db
  • PostgreSQL: postgresql://user:pass@host:5432/dbname
  • MySQL: mysql://user:pass@host:3306/dbname
  • SQL Server: mssql://user:pass@host:1433/dbname

Alternatively, you can configure your connection by setting environment variables:

export DATABASE_URL="postgresql://user:pass@host:5432/dbname"

SQL Buddy Data Schema & Taxonomy

Data Directory & Configuration

All connection settings and local cache data are stored in the user's home directory.

Path Description
~/.openclaw/data/sql-buddy/connections.json Stores configured connection strings and database credentials locally.

Schema Discovery & Security Masking

To ensure security and compliance, schema information sent to the LLM is processed according to these rules:

  • Context Extraction: Only table structures, column names, column data types, and primary/foreign keys are sent to the AI context.
  • Data Privacy: No row-level table data is sent to the LLM.
  • Sensitivity Masking: Highly sensitive field names (e.g., password_hash, secret, token) are automatically masked or excluded from schema contexts to prevent unintended data exposure.

SQL Buddy Advanced Features

  • Write Safety Override: Force write operations (INSERT, UPDATE, DELETE) by explicitly specifying the --allow-write parameter.
  • Index Recommendations: Suggest optimized database indexes based on automated query execution plans (EXPLAIN).
  • Flexible Output Formats: Export structured database query results directly to Markdown, JSON, CSV, or formatted ASCII tables.
  • Dialect Adaptation: Automatically adapts SQL generation to SQLite, PostgreSQL, MySQL, and Microsoft SQL Server nuances.
  • Result Insight Engine: Processes raw database query results using AI to return text-based summaries and highlighting data anomalies.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*