Skip to content

sql-from-text

by official

Data

Generate SQL from natural language

data sql generation
# sql-from-text

Generate SQL from natural language descriptions using AI.

## Installation

This is a CmdForge tool. Install it from the registry:

```bash
cmdforge install sql-from-text
```

## Usage

Pipe natural language descriptions to generate SQL queries:

```bash
# Basic query generation
echo "get all users from the users table" | sql-from-text

# Generate with specific dialect
echo "find products with price greater than 100" | sql-from-text --dialect MySQL

# Complex query
echo "join orders and customers tables, show customer name and total order value, group by customer" | sql-from-text

# Save to file
echo "create a table for blog posts with id, title, content, and published_date" | sql-from-text > schema.sql
```

## Arguments

| Flag | Default | Description |
|------|---------|-------------|
| `--dialect` | PostgreSQL | SQL dialect to generate (e.g., PostgreSQL, MySQL, SQLite, Oracle) |

## How It Works

1. **AI Generation**: Sends your natural language description to Claude Haiku, which generates syntactically correct SQL for the specified dialect
2. **Output**: Returns the generated SQL query ready to use

The tool uses a single AI prompt step optimized for SQL generation, making it fast and cost-effective for database query creation.

## Dependencies

None

No reviews yet.

Issues

No issues reported for this tool.