demo

command
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

README

tinySQL SQL Playground (demo)

A practical SQL playground that seeds sample data into an in-memory (or file-backed) tinySQL database and lets you explore it interactively or via a SQL script.

Features

  • Seed mode – Creates users and orders tables with realistic sample data.
  • Feature tour – Runs a guided tour of tinySQL capabilities (JOINs, GROUP BY, JSON extraction, CTEs, temp tables, UPDATE/DELETE).
  • Script mode – Executes any SQL script file (.sql) statement by statement.
  • Interactive REPL – Drops into a live SQL shell after setup.
  • Timer – Optionally prints per-statement execution time.
  • Persistent storage – Point at a file-based DSN to persist data across runs.

Build

go build -o demo .

Usage

demo [OPTIONS]

Options:
  -dsn string       Storage DSN (default: in-memory)
                      mem://?tenant=default
                      file:/tmp/mydb.db?tenant=main&autosave=1
  -seed             Populate sample tables (default: true)
  -script FILE      Execute SQL statements from FILE
  -interactive      Start interactive SQL shell after setup
  -timer            Print execution time for every statement
  -quiet            Suppress DDL/DML confirmation output

Examples

Built-in feature tour (default)
./demo

Runs the full feature tour against freshly seeded sample data.

Execute a SQL script
./demo -script my_queries.sql

Executes every statement in my_queries.sql against the seeded users/orders tables.

Interactive playground
./demo -interactive

Seeds sample data and opens a REPL where you can enter any SQL:

tinySQL playground — type SQL ending with ';' to execute, '.quit' to exit.
  .tables   list tables      .help   show this message

sql> SELECT name, email FROM users WHERE active = TRUE;
name   email
-----  -----------------
Alice  alice@example.com
Bob    NULL
(2 row(s))

sql> .quit
Bye.
Persistent database
./demo -dsn "file:/tmp/mydb.db?tenant=main" -interactive

The database is saved to /tmp/mydb.db; run again without -seed to keep existing data:

./demo -dsn "file:/tmp/mydb.db?tenant=main" -seed=false -interactive
Skip seeding, run a script on an existing database
./demo -dsn "file:/tmp/mydb.db?tenant=main" -seed=false -script report.sql
Time every statement
./demo -timer -script heavy_queries.sql

Sample data

After seeding, two tables are available:

users (id INT, name TEXT, email TEXT, active BOOL)

id name email active
1 Alice alice@example.com true
2 Bob NULL true
3 Carol carol@example.com NULL

orders (id INT, user_id INT, amount FLOAT, status TEXT, meta JSON)

id user_id amount status
101 1 100.5 PAID
102 1 75.0 PAID
103 2 200.0 PAID
104 2 20.0 CANCELED

Documentation

Overview

Package main provides a practical SQL playground for tinySQL.

It seeds sample tables (users, orders) and then lets you:

  • run any SQL script file via -script
  • drop into an interactive REPL via -interactive
  • time every statement via -timer
  • export query results in multiple formats via -output
  • import CSV/JSON files via .import command in REPL

Usage:

demo [OPTIONS]
  -dsn string        Storage DSN (default: in-memory)
  -seed              Populate sample tables (default: true)
  -script FILE       Execute SQL statements from FILE
  -interactive       Start interactive SQL shell after setup
  -timer             Print execution time for every statement
  -quiet             Suppress DDL/DML output; show only query results
  -output FORMAT     Output format: table, csv, json (default: table)

Jump to

Keyboard shortcuts

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