Natural Language to SQL

Database First.

Convert plain English questions into safe, optimized SQL queries. Powered by 100+ LLM providers with enterprise-grade security.

CLI REST API Python PHP Node.js Go
SmartQL Interactive Shell
Enter natural language questions to generate SQL.
Commands: /help, /schema, /execute, /clear, /quit
> /execute
Auto-execute mode: ON
> Show me top 5 customers by total spending
SELECT c.name, SUM(o.total) AS spending
FROM customers c
JOIN orders o ON o.customer_id = c.id
GROUP BY c.id
ORDER BY spending DESC LIMIT 5
Results: 5 rows
{'name': 'Acme Corp', 'spending': 24500.00}
{'name': 'TechStart Inc', 'spending': 18200.00}
{'name': 'Global Trade', 'spending': 15800.00}
{'name': 'DataFlow LLC', 'spending': 12400.00}
{'name': 'CloudNine', 'spending': 9850.00}
> _

Why SmartQL?

🤖

100+ LLM Providers

OpenAI, Claude, Gemini, Groq, Ollama, and more via LiteLLM. Switch providers with one line.

🔒

Enterprise Security

AST-based SQL validation with sqlglot. Table allowlists, column blocking, query limits.

📊

Semantic Layer

YAML-based configuration with business context, aliases, and rules. Your database, your language.

🔍

Auto-Introspection

Automatically discover your database schema. Works out of the box with zero configuration.

Fast & Local

Run with local models via Ollama. No data leaves your infrastructure.

🛠️

CLI & API

Interactive shell for testing. REST API for integration. Python library for embedding.

How It Works

1

Connect Your Database

database:
  type: mysql
  connection:
    host: localhost
    database: myapp
2

Choose Your LLM

llm:
  provider: groq
  groq:
    model: llama-3.1-8b-instant
3

Ask Questions

from smartql import SmartQL

sql = SmartQL.from_yaml("config.yml")
result = sql.ask("Top 10 customers by revenue")

Works With Your Stack

PostgreSQL MySQL SQLite SQL Server

Ready to Query in Plain English?

Get started in minutes. Open source and free forever.