tinySQL Interactive REPL (repl)

April 24, 2026 ยท View on GitHub

An interactive SQL shell built on top of Go's database/sql interface and the tinySQL driver. Supports multiple output formats, echo mode, optional HTML output, and in-memory or file-backed databases.

Build

go build -o repl ./cmd/repl

Usage

repl [FLAGS]

Flags:
  -dsn string
        Storage DSN (default: in-memory)
        Examples:
          mem://?tenant=default
          file:/tmp/mydb.db?tenant=main&autosave=1
  -format string
        Output format: table | csv | tsv | json | yaml | markdown (default: "table")
  -echo
        Echo each SQL statement before executing it
  -beautiful
        Enable enhanced table borders (box-drawing characters)
  -html
        Emit results as HTML tables instead of text
  -errors-only
        Suppress successful results; only print errors

Quick start

In-memory database (default)

./repl

File-backed database

./repl -dsn "file:/tmp/demo.db?tenant=main&autosave=1"

JSON output format

./repl -format json

Markdown output (great for copy-paste into docs)

./repl -format markdown

Interactive commands

Inside the REPL, type any SQL statement ending with ; to execute it. Special dot-commands:

CommandDescription
.quit / .exitExit the REPL
.tablesList all tables
.schema <table>Show CREATE TABLE statement
.helpShow available commands

Output formats

FormatDescription
tableASCII-aligned columns (default)
csvComma-separated values
tsvTab-separated values
jsonJSON array of objects
yamlYAML sequence
markdownGitHub-flavoured Markdown table

Example session

tinySQL repl โ€” type SQL ending with ';' or a dot-command.

sql> CREATE TABLE users (id INT, name TEXT, active BOOL);
(ok)

sql> INSERT INTO users VALUES (1, 'Alice', TRUE), (2, 'Bob', FALSE);
(2 row(s) affected)

sql> SELECT * FROM users WHERE active = TRUE;
 id | name
----+------
  1 | Alice
(1 row(s))

sql> .tables
users

sql> .quit
Bye.