Start cross-linking CLI to Python docs, refs #426

This commit is contained in:
Simon Willison 2022-08-02 09:17:45 -07:00
commit e193aa910e
2 changed files with 92 additions and 0 deletions

View file

@ -63,6 +63,7 @@ This page lists the ``--help`` for every ``sqlite-utils`` CLI sub-command.
commands.sort(key = lambda command: go_first.index(command) if command in go_first else 999) commands.sort(key = lambda command: go_first.index(command) if command in go_first else 999)
cog.out("\n") cog.out("\n")
for command in commands: for command in commands:
cog.out(".. _cli_ref_" + command.replace("-", "_") + ":\n\n")
cog.out(command + "\n") cog.out(command + "\n")
cog.out(("=" * len(command)) + "\n\n") cog.out(("=" * len(command)) + "\n\n")
if command in refs: if command in refs:
@ -81,6 +82,8 @@ This page lists the ``--help`` for every ``sqlite-utils`` CLI sub-command.
cog.out("\n\n") cog.out("\n\n")
.. ]]] .. ]]]
.. _cli_ref_query:
query query
===== =====
@ -120,6 +123,8 @@ See :ref:`cli_query`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_memory:
memory memory
====== ======
@ -184,6 +189,8 @@ See :ref:`cli_memory`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_insert:
insert insert
====== ======
@ -264,6 +271,8 @@ See :ref:`cli_inserting_data`, :ref:`cli_insert_csv_tsv`, :ref:`cli_insert_unstr
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_upsert:
upsert upsert
====== ======
@ -312,6 +321,8 @@ See :ref:`cli_upsert`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_bulk:
bulk bulk
==== ====
@ -352,6 +363,8 @@ See :ref:`cli_bulk`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_search:
search search
====== ======
@ -390,6 +403,8 @@ See :ref:`cli_search`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_transform:
transform transform
========= =========
@ -424,6 +439,8 @@ See :ref:`cli_transform_table`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_extract:
extract extract
======= =======
@ -447,6 +464,8 @@ See :ref:`cli_extract`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_schema:
schema schema
====== ======
@ -467,6 +486,8 @@ See :ref:`cli_schema`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_insert_files:
insert-files insert-files
============ ============
@ -503,6 +524,8 @@ See :ref:`cli_insert_files`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_analyze_tables:
analyze-tables analyze-tables
============== ==============
@ -525,6 +548,8 @@ See :ref:`cli_analyze_tables`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_convert:
convert convert
======= =======
@ -590,6 +615,8 @@ See :ref:`cli_convert`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_tables:
tables tables
====== ======
@ -628,6 +655,8 @@ See :ref:`cli_tables`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_views:
views views
===== =====
@ -664,6 +693,8 @@ See :ref:`cli_views`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_rows:
rows rows
==== ====
@ -702,6 +733,8 @@ See :ref:`cli_rows`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_triggers:
triggers triggers
======== ========
@ -735,6 +768,8 @@ See :ref:`cli_triggers`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_indexes:
indexes indexes
======= =======
@ -769,6 +804,8 @@ See :ref:`cli_indexes`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_create_database:
create-database create-database
=============== ===============
@ -791,6 +828,8 @@ See :ref:`cli_create_database`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_create_table:
create-table create-table
============ ============
@ -821,6 +860,8 @@ See :ref:`cli_create_table`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_create_index:
create-index create-index
============ ============
@ -849,6 +890,8 @@ See :ref:`cli_create_index`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_enable_fts:
enable-fts enable-fts
========== ==========
@ -875,6 +918,8 @@ See :ref:`cli_fts`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_populate_fts:
populate-fts populate-fts
============ ============
@ -893,6 +938,8 @@ populate-fts
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_rebuild_fts:
rebuild-fts rebuild-fts
=========== ===========
@ -911,6 +958,8 @@ rebuild-fts
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_disable_fts:
disable-fts disable-fts
=========== ===========
@ -929,6 +978,8 @@ disable-fts
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_optimize:
optimize optimize
======== ========
@ -951,6 +1002,8 @@ See :ref:`cli_optimize`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_analyze:
analyze analyze
======= =======
@ -971,6 +1024,8 @@ See :ref:`cli_analyze`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_vacuum:
vacuum vacuum
====== ======
@ -990,6 +1045,8 @@ See :ref:`cli_vacuum`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_dump:
dump dump
==== ====
@ -1010,6 +1067,8 @@ See :ref:`cli_dump`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_add_column:
add-column add-column
========== ==========
@ -1036,6 +1095,8 @@ See :ref:`cli_add_column`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_add_foreign_key:
add-foreign-key add-foreign-key
=============== ===============
@ -1060,6 +1121,8 @@ See :ref:`cli_add_foreign_key`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_add_foreign_keys:
add-foreign-keys add-foreign-keys
================ ================
@ -1082,6 +1145,8 @@ See :ref:`cli_add_foreign_keys`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_index_foreign_keys:
index-foreign-keys index-foreign-keys
================== ==================
@ -1102,6 +1167,8 @@ See :ref:`cli_index_foreign_keys`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_enable_wal:
enable-wal enable-wal
========== ==========
@ -1122,6 +1189,8 @@ See :ref:`cli_wal`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_disable_wal:
disable-wal disable-wal
=========== ===========
@ -1140,6 +1209,8 @@ disable-wal
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_enable_counts:
enable-counts enable-counts
============= =============
@ -1160,6 +1231,8 @@ See :ref:`cli_enable_counts`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_reset_counts:
reset-counts reset-counts
============ ============
@ -1178,6 +1251,8 @@ reset-counts
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_duplicate:
duplicate duplicate
========= =========
@ -1193,6 +1268,8 @@ duplicate
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_drop_table:
drop-table drop-table
========== ==========
@ -1214,6 +1291,8 @@ See :ref:`cli_drop_table`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_create_view:
create-view create-view
=========== ===========
@ -1237,6 +1316,8 @@ See :ref:`cli_create_view`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_drop_view:
drop-view drop-view
========= =========
@ -1258,6 +1339,8 @@ See :ref:`cli_drop_view`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_add_geometry_column:
add-geometry-column add-geometry-column
=================== ===================
@ -1287,6 +1370,8 @@ See :ref:`cli_spatialite`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_create_spatial_index:
create-spatial-index create-spatial-index
==================== ====================

View file

@ -21,6 +21,9 @@ The ``sqlite-utils query`` command lets you run queries directly against a SQLit
$ sqlite-utils query dogs.db "select * from dogs" $ sqlite-utils query dogs.db "select * from dogs"
$ sqlite-utils dogs.db "select * from dogs" $ sqlite-utils dogs.db "select * from dogs"
.. note::
In Python: :ref:`db.query() <python_api_query>` CLI reference: :ref:`sqlite-utils query <cli_ref_query>`
.. _cli_query_json: .. _cli_query_json:
Returning JSON Returning JSON
@ -257,6 +260,7 @@ You can load SQLite extension modules using the ``--load-extension`` option, see
$ sqlite-utils dogs.db "select spatialite_version()" --load-extension=spatialite $ sqlite-utils dogs.db "select spatialite_version()" --load-extension=spatialite
[{"spatialite_version()": "4.3.0a"}] [{"spatialite_version()": "4.3.0a"}]
.. _cli_query_attach: .. _cli_query_attach:
Attaching additional databases Attaching additional databases
@ -271,6 +275,9 @@ This example attaches the ``books.db`` database under the alias ``books`` and th
sqlite-utils dogs.db --attach books books.db \ sqlite-utils dogs.db --attach books books.db \
'select * from sqlite_master union all select * from books.sqlite_master' 'select * from sqlite_master union all select * from books.sqlite_master'
.. note::
In Python: :ref:`db.attach() <python_api_attach>`
.. _cli_memory: .. _cli_memory:
Querying data directly using an in-memory database Querying data directly using an in-memory database