SQLite User Forum

CLI: Help output should indicate that multiple SQL queries/dot commands can be provided
Login

CLI: Help output should indicate that multiple SQL queries/dot commands can be provided

(1) By anonymous on 2025-02-18 20:10:28 [source]

The CLI help currently reads as if only one SQL query/dot command can be provided:

$ sqlite3 -help
Usage: sqlite3 [OPTIONS] [FILENAME [SQL]]

For SQL, one can separate multiple queries with semicolons; this does not work for dot commands though (based on testing). It is possible though to just provide multiple strings.

Example:

$ sqlite3 :memory: 'SELECT 42'
42

$ sqlite3 :memory: 'SELECT 42; SELECT 43'
42
43

$ sqlite3 :memory: '.mode json; SELECT 42; SELECT 43;'
extra argument: "42;"

$ sqlite3 :memory: '.mode json' 'SELECT 42; SELECT 43;'
[{"42":42}]
[{"43":43}]

Thus, it would be nice if the help output could be adjusted to e.g. (as for vim -h)

Usage: sqlite3 [OPTIONS] [FILENAME [SQL ...]]
or (as for ls --help)
Usage: sqlite3 [OPTIONS] [FILENAME [SQL]...]

(2) By Adrian Ho (lexfiend) on 2025-02-19 05:14:08 in reply to 1 [link] [source]

That seems like a logical follow-through to https://sqlite.org/forum/forumpost/3467af87037f0cda.

(3) By anonymous on 2025-02-20 14:05:38 in reply to 2 [link] [source]

Indeed - thanks; added a reference over there.

(4) By anonymous on 2025-02-20 16:34:38 in reply to 3 [link] [source]

Implemented in 82fc67070f9aff00 :)