demo

command
v0.71.0 Latest Latest
Warning

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

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

README

tinySQL SQL Playground (demo)

Part of tinySQL. Use the root guide for the current feature, GIS, storage, and import overview.

Seeds sample data into an in-memory or file-backed tinySQL database and lets you explore it via a guided feature tour, a SQL script, or an interactive REPL.

Build

go build -o demo .

Usage

demo [OPTIONS]

Options:
  -dsn string       Storage DSN (default: 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; only SELECT results
  -output string    Output format: table (default), csv, json, ndjson

Without -script or -interactive, the default run is a feature tour covering joins, PIVOT/window functions, JSON, triggers, full-text search, vector search, CTEs, geospatial distance and bearing, temp tables, and UPDATE/DELETE.

Examples

./demo                                   # feature tour on freshly seeded data
./demo -script my_queries.sql            # run a script against seeded tables
./demo -interactive                      # seed, then open a REPL
./demo -timer -script heavy_queries.sql  # time every statement
./demo -output ndjson -script report.sql | jq -c .

# Persist to a file, then reuse it without reseeding
./demo -dsn "file:/tmp/mydb.db?tenant=main" -interactive
./demo -dsn "file:/tmp/mydb.db?tenant=main" -seed=false -script report.sql

REPL session:

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.

Sample data

Seeding creates users, orders, order_audit, sales, articles, and docs. The users and orders tables drive ordinary query examples; order_audit records inserted orders through an AFTER INSERT trigger, and the remaining tables drive PIVOT/window, full-text, and vector-search steps.

Documentation

Overview

Package main provides a practical SQL playground for tinySQL.

It seeds sample tables (users, orders, sales, articles, docs) 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

The built-in feature tour (run with no -script/-interactive flag) covers PIVOT, window functions (RANK/DENSE_RANK/PERCENT_RANK/CUME_DIST/NTILE), FULL OUTER / CROSS JOIN, whole-row full-text search (FTS_SEARCH and ROW_TO_TEXT), vector search with VEC_WARM index warm-up, and the SQL:2008 OFFSET ... FETCH syntax, alongside traditional JOIN/GROUP BY/aggregate queries. It also shows a row trigger that writes an audit log whenever a new order is inserted.

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, ndjson (default: table)

Jump to

Keyboard shortcuts

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