tables and views commands accept optional table/view names

The tables and views commands now take one or more optional table (or view)
names as positional arguments after the database path, restricting the output
to just those tables. This is handy with --counts against a database that has
a large table you would rather skip.

Names are listed in the order they are passed. If any named table or view does
not exist the command raises an error and exits with a non-zero status, so the
exit code can be used to confirm a set of expected tables is present.

Closes #478
This commit is contained in:
Chris (ChrisJr404) 2026-08-18 06:22:20 -04:00
commit 81e2ad8a44
No known key found for this signature in database
4 changed files with 109 additions and 3 deletions

View file

@ -711,7 +711,7 @@ See :ref:`cli_tables`.
::
Usage: sqlite-utils tables [OPTIONS] PATH
Usage: sqlite-utils tables [OPTIONS] PATH [NAMES]...
List the tables in the database
@ -719,6 +719,10 @@ See :ref:`cli_tables`.
sqlite-utils tables trees.db
Pass one or more table names to restrict the output to just those tables:
sqlite-utils tables trees.db plants seeds
Options:
--fts4 Just show FTS4 enabled tables
--fts5 Just show FTS5 enabled tables
@ -756,7 +760,7 @@ See :ref:`cli_views`.
::
Usage: sqlite-utils views [OPTIONS] PATH
Usage: sqlite-utils views [OPTIONS] PATH [NAMES]...
List the views in the database
@ -764,6 +768,10 @@ See :ref:`cli_views`.
sqlite-utils views trees.db
Pass one or more view names to restrict the output to just those views:
sqlite-utils views trees.db recent_plants
Options:
--counts Include row counts per view
--nl Output newline-delimited JSON