debug

command
v0.10.0 Latest Latest
Warning

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

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

README

tinySQL SQL Diagnostic Tool (debug)

A lightweight command-line tool for parsing and executing SQL statements against an in-memory tinySQL database. It reports the statement type, execution result, and per-statement timing — useful for quickly testing SQL compatibility and debugging query behaviour without a full REPL.

Build

go build -o debug ./cmd/debug

Usage

debug [FLAGS] [SQL...]

Flags:
  -sql      SQL statement(s) to execute (semicolon-separated)
  -timing   Print execution time for each statement (default: true)
  -verbose  Print statement type and extra diagnostics (default: false)

SQL can be provided in three ways, evaluated in this order:

  1. -sql flag
  2. Positional arguments (joined with a space)
  3. Standard input (when stdin is not a TTY)

Multiple semicolon-separated statements are accepted in all three modes.

Examples

Via -sql flag
./debug -sql "SELECT 1 + 1 AS result"
Positional argument
./debug "SELECT UPPER('hello') AS greeting"
Multiple statements
./debug "CREATE TABLE t (id INT, name TEXT); INSERT INTO t VALUES (1, 'Alice'); SELECT * FROM t"
Pipe from stdin
echo "SELECT 42 AS answer" | ./debug
With verbose output
./debug -verbose -sql "SELECT COUNT(*) FROM (VALUES (1),(2),(3)) AS x(n)"
Suppress timing
./debug -timing=false -sql "SELECT NOW()"

Sample output

[1] SQL> SELECT 1 + 1 AS result
    result
    ------
    2
    (1 row(s))
    elapsed: 48µs

[2] SQL> CREATE TABLE t (id INT, name TEXT)
    (ok)
    elapsed: 12µs

[3] SQL> INSERT INTO t VALUES (1, 'Alice')
    (0 rows)
    elapsed: 9µs

[4] SQL> SELECT * FROM t
    id  name
    --  -----
    1   Alice
    (1 row(s))
    elapsed: 6µs

Notes

  • Each run starts with a fresh in-memory database; data does not persist between invocations.
  • The tool is intended as a development aid, not an end-user application. For a persistent interactive shell see tinysql or repl.

Documentation

Overview

debug – tinySQL SQL diagnostic tool.

Parses and executes SQL statements against an in-memory tinySQL database, reporting the statement type, execution time, and results. Useful for quickly testing SQL compatibility and debugging query behaviour.

SQL can be provided via the -sql flag, as positional arguments, or read from stdin when no flags are given.

Usage:

debug -sql "SELECT 1 + 1 AS result"
debug "CREATE TABLE t (id INT); INSERT INTO t VALUES (1); SELECT * FROM t"
echo "SELECT 42 AS answer" | debug

Flags:

-sql      SQL statement(s) to execute (semicolon-separated)
-dsn      Storage DSN (default: in-memory)
-timing   Print execution time for each statement
-verbose  Print statement type and extra diagnostics

Jump to

Keyboard shortcuts

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