← All posts

SmartQL 0.1.0 Is on PyPI

SmartQL 0.1.0 is out. You can install it now:

pip install smartql

SmartQL turns plain English questions into SQL, runs them against your database, and refuses to run anything it cannot prove is safe. It is open source under the MIT license.

What is in 0.1.0

Three ways to use it. An interactive CLI shell for exploring a database by conversation, a REST API for wiring it into your product, and a Python library for embedding it directly:

from smartql import SmartQL

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

100+ LLM providers. OpenAI, Anthropic, Gemini, Groq, and everything else LiteLLM speaks. Switching providers is one line of YAML. Ollama is supported for setups where no data may leave your network.

AST-based SQL validation. Every generated query is parsed with sqlglot before execution. Read-only mode rejects anything that is not a SELECT by statement type, not by string matching. Table allowlists, blocked columns, join limits, and complexity caps are all enforced on the parse tree, and a LIMIT is injected when the model forgets one. The reasoning behind this design has its own post.

A YAML semantic layer. Describe what your tables and columns actually mean, define business terms like “revenue” and “churned” once, and the model stops guessing. Schemas are also auto-introspected, so an empty config still works.

Ask in any language. The question is passed straight to the model, with no English-only assumption, so a question in Spanish, French, or Arabic returns SQL just the same. Coverage depends on the model you pick.

Four databases. PostgreSQL, MySQL, SQLite, and SQL Server.

Getting started

A minimal config is a database connection and an LLM provider:

version: "1.0"

database:
  type: mysql
  connection:
    host: localhost
    database: myapp
    user: ${DB_USER}
    password: ${DB_PASSWORD}

llm:
  provider: groq
  groq:
    api_key: ${GROQ_API_KEY}
    model: llama-3.1-8b-instant

security:
  mode: read_only
  max_rows: 1000

Then ask:

smartql shell -c smartql.yml

There is also a Docker image at ghcr.io/smartql/smartql if you would rather not touch your Python environment.

What is next

PHP, Node.js, and Go client libraries are in progress, along with deeper semantic layer tooling. The roadmap lives in the GitHub issues; if SmartQL almost fits your use case but not quite, that is exactly the feedback we want right now.

Full setup details are in the docs.

Star on GitHub