tinySQL SQL Toolkit (sqltools)

April 24, 2026 · View on GitHub

A multi-purpose SQL utility that bundles a formatter, validator, query explainer, template library, and interactive REPL into a single binary.

Build

go build -o sqltools ./cmd/sqltools

Usage

sqltools <subcommand> [options] [args...]

Subcommands

beautify — Format a SQL statement

./sqltools beautify "select id,name from users where id=1"

Output:

SELECT
  id,
  name
FROM
  users
WHERE
  id = 1

Options:

FlagDescriptionDefault
-upperConvert keywords to uppercasetrue

validate — Check SQL syntax

./sqltools validate "SELECT * FROM users WHERE"
# exit code 1 + error message on invalid SQL

./sqltools validate "SELECT id FROM users"
# exit code 0 + "OK"

explain — Show a query execution plan

Parses the SQL and prints a human-readable description of the execution steps tinySQL would use (table scan, join order, filter pushdown, etc.).

./sqltools explain "SELECT u.name, COUNT(o.id) FROM users u LEFT JOIN orders o ON u.id = o.user_id GROUP BY u.name"

templates — List built-in query templates

Prints a catalogue of common SQL patterns (CREATE TABLE, SELECT with JOIN, CTE, window function, etc.) that can be used as starting points.

./sqltools templates

repl — Interactive SQL tools shell

An enhanced REPL with schema browsing, query history, and access to all subcommands as slash-commands.

./sqltools repl
./sqltools repl -tenant mydb

Options:

FlagDescriptionDefault
-tenantTenant name for the in-memory databasedefault

Inside the REPL:

CommandDescription
/beautify <sql>Format a statement
/validate <sql>Validate syntax
/explain <sql>Show execution plan
/templatesList templates
.tablesList tables
.schema <table>Show table schema
.helpShow help
.quitExit

Examples

# Format and validate in one pipeline
./sqltools beautify "select*from t" | ./sqltools validate

# Quick explain from a file
cat query.sql | xargs ./sqltools explain

# Start interactive session against an in-memory tenant
./sqltools repl -tenant analytics