repl

command
v0.73.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

README

tinySQL Interactive REPL (repl)

Part of tinySQL. See the root guide for supported SQL, storage modes, and limitations.

An interactive SQL shell over database/sql and the tinySQL driver.

Build

mkdir -p bin
go build -o bin/repl ./cmd/repl

Usage

repl [FLAGS]

Flags:
  -dsn string
        Storage DSN (default "mem://?tenant=default")
        e.g. 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
        Pretty-print SQL blocks and results (groups statements until the next SELECT)
  -html
        Emit a single HTML page of SQL blocks and results (for redirected input)
  -errors-only
        Only print queries/results that produce errors
./bin/repl
./bin/repl -dsn "file:/tmp/demo.db?tenant=main&autosave=1"
./bin/repl -format json
./bin/repl -format markdown

markdown emits GitHub-flavoured tables; json an array of objects; yaml a sequence. md is accepted as an alias for markdown.

Result readers reuse their scan buffers while keeping each displayed row and BLOB value independent. Table and HTML output still retain the result set for rendering. -errors-only consumes SELECT results without retaining display rows, so errors raised during lazy row evaluation are reported as well.

Interactive commands

Type SQL ending with ; to execute. Dot-commands:

Command Description
.help Show available commands
.quit / .exit Exit
.tables List all tables
.schema [TABLE] Show CREATE TABLE (all tables, or one)
.count [TABLE...] Show row counts
.dump [TABLE...] Dump table(s) as INSERT statements
.read FILE Execute SQL from a file
.clear Clear the screen

Choose the output format with -format. The built-in help currently lists .output and .timer, but those commands are not available.

Example session

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> .quit

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL