Skip to content

Commit 4c60234

Browse files
committed
Examples in --help for remaining commands, closes #384
1 parent 6e85a4b commit 4c60234

File tree

2 files changed

+297
-54
lines changed

2 files changed

+297
-54
lines changed

docs/cli-reference.rst

Lines changed: 117 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,10 @@ See :ref:`cli_views`.
605605

606606
List the views in the database
607607

608+
Example:
609+
610+
sqlite-utils views trees.db
611+
608612
Options:
609613
--counts Include row counts per view
610614
--nl Output newline-delimited JSON
@@ -637,6 +641,10 @@ See :ref:`cli_rows`.
637641

638642
Output all rows in the specified table
639643

644+
Example:
645+
646+
sqlite-utils rows trees.db Trees
647+
640648
Options:
641649
-c, --column TEXT Columns to return
642650
--where TEXT Optional where clause
@@ -671,6 +679,10 @@ See :ref:`cli_triggers`.
671679

672680
Show triggers configured in this database
673681

682+
Example:
683+
684+
sqlite-utils triggers trees.db
685+
674686
Options:
675687
--nl Output newline-delimited JSON
676688
--arrays Output rows as arrays instead of objects
@@ -698,7 +710,11 @@ See :ref:`cli_indexes`.
698710

699711
Usage: sqlite-utils indexes [OPTIONS] PATH [TABLES]...
700712

701-
Show indexes for this database
713+
Show indexes for the whole database or specific tables
714+
715+
Example:
716+
717+
sqlite-utils indexes trees.db Trees
702718

703719
Options:
704720
--aux Include auxiliary columns
@@ -728,7 +744,11 @@ See :ref:`cli_create_database`.
728744

729745
Usage: sqlite-utils create-database [OPTIONS] PATH
730746

731-
Create a new empty database file.
747+
Create a new empty database file
748+
749+
Example:
750+
751+
sqlite-utils create-database trees.db
732752

733753
Options:
734754
--enable-wal Enable WAL mode on the created database
@@ -747,11 +767,11 @@ See :ref:`cli_create_table`.
747767
Add a table with the specified columns. Columns should be specified using
748768
name, type pairs, for example:
749769

750-
sqlite-utils create-table my.db people \
751-
id integer \
752-
name text \
753-
height float \
754-
photo blob --pk id
770+
sqlite-utils create-table my.db people \
771+
id integer \
772+
name text \
773+
height float \
774+
photo blob --pk id
755775

756776
Options:
757777
--pk TEXT Column to use as primary key
@@ -774,9 +794,15 @@ See :ref:`cli_create_index`.
774794

775795
Usage: sqlite-utils create-index [OPTIONS] PATH TABLE COLUMN...
776796

777-
Add an index to the specified table covering the specified columns. Use
778-
"sqlite-utils create-index mydb -- -column" to specify descending order for a
779-
column.
797+
Add an index to the specified table for the specified columns
798+
799+
Example:
800+
801+
sqlite-utils create-index chickens.db chickens name
802+
803+
To create an index in descending order:
804+
805+
sqlite-utils create-index chickens.db chickens -- -name
780806

781807
Options:
782808
--name TEXT Explicit name for the new index
@@ -796,7 +822,11 @@ See :ref:`cli_fts`.
796822

797823
Usage: sqlite-utils enable-fts [OPTIONS] PATH TABLE COLUMN...
798824

799-
Enable full-text search for specific table and columns
825+
Enable full-text search for specific table and columns"
826+
827+
Example:
828+
829+
sqlite-utils enable-fts chickens.db chickens name
800830

801831
Options:
802832
--fts4 Use FTS4
@@ -817,6 +847,10 @@ populate-fts
817847

818848
Re-populate full-text search for specific table and columns
819849

850+
Example:
851+
852+
sqlite-utils populate-fts chickens.db chickens name
853+
820854
Options:
821855
--load-extension TEXT SQLite extensions to load
822856
-h, --help Show this message and exit.
@@ -831,6 +865,10 @@ rebuild-fts
831865

832866
Rebuild all or specific full-text search tables
833867

868+
Example:
869+
870+
sqlite-utils rebuild-fts chickens.db chickens
871+
834872
Options:
835873
--load-extension TEXT SQLite extensions to load
836874
-h, --help Show this message and exit.
@@ -845,6 +883,10 @@ disable-fts
845883

846884
Disable full-text search for specific table
847885

886+
Example:
887+
888+
sqlite-utils disable-fts chickens.db chickens
889+
848890
Options:
849891
--load-extension TEXT SQLite extensions to load
850892
-h, --help Show this message and exit.
@@ -862,6 +904,10 @@ See :ref:`cli_optimize`.
862904
Optimize all full-text search tables and then run VACUUM - should shrink the
863905
database file
864906

907+
Example:
908+
909+
sqlite-utils optimize chickens.db
910+
865911
Options:
866912
--no-vacuum Don't run VACUUM
867913
--load-extension TEXT SQLite extensions to load
@@ -880,6 +926,10 @@ See :ref:`cli_analyze`.
880926
Run ANALYZE against the whole database, or against specific named indexes and
881927
tables
882928

929+
Example:
930+
931+
sqlite-utils analyze chickens.db
932+
883933
Options:
884934
-h, --help Show this message and exit.
885935

@@ -895,6 +945,10 @@ See :ref:`cli_vacuum`.
895945

896946
Run VACUUM against the database
897947

948+
Example:
949+
950+
sqlite-utils vacuum chickens.db
951+
898952
Options:
899953
-h, --help Show this message and exit.
900954

@@ -910,6 +964,10 @@ See :ref:`cli_dump`.
910964

911965
Output a SQL dump of the schema and full contents of the database
912966

967+
Example:
968+
969+
sqlite-utils dump chickens.db
970+
913971
Options:
914972
--load-extension TEXT SQLite extensions to load
915973
-h, --help Show this message and exit.
@@ -927,6 +985,10 @@ See :ref:`cli_add_column`.
927985

928986
Add a column to the specified table
929987

988+
Example:
989+
990+
sqlite-utils add-column chickens.db chickens weight float
991+
930992
Options:
931993
--fk TEXT Table to reference as a foreign key
932994
--fk-col TEXT Referenced column on that foreign key table - if
@@ -946,9 +1008,11 @@ See :ref:`cli_add_foreign_key`.
9461008
Usage: sqlite-utils add-foreign-key [OPTIONS] PATH TABLE COLUMN [OTHER_TABLE]
9471009
[OTHER_COLUMN]
9481010

949-
Add a new foreign key constraint to an existing table. Example usage:
1011+
Add a new foreign key constraint to an existing table
9501012

951-
$ sqlite-utils add-foreign-key my.db books author_id authors id
1013+
Example:
1014+
1015+
sqlite-utils add-foreign-key my.db books author_id authors id
9521016

9531017
WARNING: Could corrupt your database! Back up your database file first.
9541018

@@ -967,11 +1031,13 @@ See :ref:`cli_add_foreign_keys`.
9671031

9681032
Usage: sqlite-utils add-foreign-keys [OPTIONS] PATH [FOREIGN_KEY]...
9691033

970-
Add multiple new foreign key constraints to a database. Example usage:
1034+
Add multiple new foreign key constraints to a database
1035+
1036+
Example:
9711037

972-
sqlite-utils add-foreign-keys my.db \
973-
books author_id authors id \
974-
authors country_id countries id
1038+
sqlite-utils add-foreign-keys my.db \
1039+
books author_id authors id \
1040+
authors country_id countries id
9751041

9761042
Options:
9771043
--load-extension TEXT SQLite extensions to load
@@ -987,7 +1053,11 @@ See :ref:`cli_index_foreign_keys`.
9871053

9881054
Usage: sqlite-utils index-foreign-keys [OPTIONS] PATH
9891055

990-
Ensure every foreign key column has an index on it.
1056+
Ensure every foreign key column has an index on it
1057+
1058+
Example:
1059+
1060+
sqlite-utils index-foreign-keys chickens.db
9911061

9921062
Options:
9931063
--load-extension TEXT SQLite extensions to load
@@ -1005,6 +1075,10 @@ See :ref:`cli_wal`.
10051075

10061076
Enable WAL for database files
10071077

1078+
Example:
1079+
1080+
sqlite-utils enable-wal chickens.db
1081+
10081082
Options:
10091083
--load-extension TEXT SQLite extensions to load
10101084
-h, --help Show this message and exit.
@@ -1019,6 +1093,10 @@ disable-wal
10191093

10201094
Disable WAL for database files
10211095

1096+
Example:
1097+
1098+
sqlite-utils disable-wal chickens.db
1099+
10221100
Options:
10231101
--load-extension TEXT SQLite extensions to load
10241102
-h, --help Show this message and exit.
@@ -1035,6 +1113,10 @@ See :ref:`cli_enable_counts`.
10351113

10361114
Configure triggers to update a _counts table with row counts
10371115

1116+
Example:
1117+
1118+
sqlite-utils enable-counts chickens.db
1119+
10381120
Options:
10391121
--load-extension TEXT SQLite extensions to load
10401122
-h, --help Show this message and exit.
@@ -1049,6 +1131,10 @@ reset-counts
10491131

10501132
Reset calculated counts in the _counts table
10511133

1134+
Example:
1135+
1136+
sqlite-utils reset-counts chickens.db
1137+
10521138
Options:
10531139
--load-extension TEXT SQLite extensions to load
10541140
-h, --help Show this message and exit.
@@ -1065,6 +1151,10 @@ See :ref:`cli_drop_table`.
10651151

10661152
Drop the specified table
10671153

1154+
Example:
1155+
1156+
sqlite-utils drop-table chickens.db chickens
1157+
10681158
Options:
10691159
--ignore
10701160
--load-extension TEXT SQLite extensions to load
@@ -1082,6 +1172,11 @@ See :ref:`cli_create_view`.
10821172

10831173
Create a view for the provided SELECT query
10841174

1175+
Example:
1176+
1177+
sqlite-utils create-view chickens.db heavy_chickens \
1178+
'select * from chickens where weight > 3'
1179+
10851180
Options:
10861181
--ignore If view already exists, do nothing
10871182
--replace If view already exists, replace it
@@ -1100,6 +1195,10 @@ See :ref:`cli_drop_view`.
11001195

11011196
Drop the specified view
11021197

1198+
Example:
1199+
1200+
sqlite-utils drop-view chickens.db heavy_chickens
1201+
11031202
Options:
11041203
--ignore
11051204
--load-extension TEXT SQLite extensions to load

0 commit comments

Comments
 (0)