From f4fb78fa95057fbc86c734020835a3155695297f Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 18 Aug 2022 14:58:07 -0700 Subject: [PATCH] Cross-link CLI to Python docs (#460) * Start cross-linking CLI to Python docs, refs #426 * More links to Python from CLI page, refs #426 --- docs/cli-reference.rst | 85 ++++++++++++++++++++++++++++++++++++++++++ docs/cli.rst | 25 +++++++++++++ 2 files changed, 110 insertions(+) diff --git a/docs/cli-reference.rst b/docs/cli-reference.rst index 86225aa..2590595 100644 --- a/docs/cli-reference.rst +++ b/docs/cli-reference.rst @@ -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) cog.out("\n") for command in commands: + cog.out(".. _cli_ref_" + command.replace("-", "_") + ":\n\n") cog.out(command + "\n") cog.out(("=" * len(command)) + "\n\n") if command in refs: @@ -81,6 +82,8 @@ This page lists the ``--help`` for every ``sqlite-utils`` CLI sub-command. cog.out("\n\n") .. ]]] +.. _cli_ref_query: + query ===== @@ -120,6 +123,8 @@ See :ref:`cli_query`. -h, --help Show this message and exit. +.. _cli_ref_memory: + memory ====== @@ -184,6 +189,8 @@ See :ref:`cli_memory`. -h, --help Show this message and exit. +.. _cli_ref_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. +.. _cli_ref_upsert: + upsert ====== @@ -312,6 +321,8 @@ See :ref:`cli_upsert`. -h, --help Show this message and exit. +.. _cli_ref_bulk: + bulk ==== @@ -352,6 +363,8 @@ See :ref:`cli_bulk`. -h, --help Show this message and exit. +.. _cli_ref_search: + search ====== @@ -390,6 +403,8 @@ See :ref:`cli_search`. -h, --help Show this message and exit. +.. _cli_ref_transform: + transform ========= @@ -424,6 +439,8 @@ See :ref:`cli_transform_table`. -h, --help Show this message and exit. +.. _cli_ref_extract: + extract ======= @@ -447,6 +464,8 @@ See :ref:`cli_extract`. -h, --help Show this message and exit. +.. _cli_ref_schema: + schema ====== @@ -467,6 +486,8 @@ See :ref:`cli_schema`. -h, --help Show this message and exit. +.. _cli_ref_insert_files: + insert-files ============ @@ -503,6 +524,8 @@ See :ref:`cli_insert_files`. -h, --help Show this message and exit. +.. _cli_ref_analyze_tables: + analyze-tables ============== @@ -525,6 +548,8 @@ See :ref:`cli_analyze_tables`. -h, --help Show this message and exit. +.. _cli_ref_convert: + convert ======= @@ -590,6 +615,8 @@ See :ref:`cli_convert`. -h, --help Show this message and exit. +.. _cli_ref_tables: + tables ====== @@ -628,6 +655,8 @@ See :ref:`cli_tables`. -h, --help Show this message and exit. +.. _cli_ref_views: + views ===== @@ -664,6 +693,8 @@ See :ref:`cli_views`. -h, --help Show this message and exit. +.. _cli_ref_rows: + rows ==== @@ -702,6 +733,8 @@ See :ref:`cli_rows`. -h, --help Show this message and exit. +.. _cli_ref_triggers: + triggers ======== @@ -735,6 +768,8 @@ See :ref:`cli_triggers`. -h, --help Show this message and exit. +.. _cli_ref_indexes: + indexes ======= @@ -769,6 +804,8 @@ See :ref:`cli_indexes`. -h, --help Show this message and exit. +.. _cli_ref_create_database: + create-database =============== @@ -791,6 +828,8 @@ See :ref:`cli_create_database`. -h, --help Show this message and exit. +.. _cli_ref_create_table: + create-table ============ @@ -821,6 +860,8 @@ See :ref:`cli_create_table`. -h, --help Show this message and exit. +.. _cli_ref_create_index: + create-index ============ @@ -849,6 +890,8 @@ See :ref:`cli_create_index`. -h, --help Show this message and exit. +.. _cli_ref_enable_fts: + enable-fts ========== @@ -875,6 +918,8 @@ See :ref:`cli_fts`. -h, --help Show this message and exit. +.. _cli_ref_populate_fts: + populate-fts ============ @@ -893,6 +938,8 @@ populate-fts -h, --help Show this message and exit. +.. _cli_ref_rebuild_fts: + rebuild-fts =========== @@ -911,6 +958,8 @@ rebuild-fts -h, --help Show this message and exit. +.. _cli_ref_disable_fts: + disable-fts =========== @@ -929,6 +978,8 @@ disable-fts -h, --help Show this message and exit. +.. _cli_ref_optimize: + optimize ======== @@ -951,6 +1002,8 @@ See :ref:`cli_optimize`. -h, --help Show this message and exit. +.. _cli_ref_analyze: + analyze ======= @@ -971,6 +1024,8 @@ See :ref:`cli_analyze`. -h, --help Show this message and exit. +.. _cli_ref_vacuum: + vacuum ====== @@ -990,6 +1045,8 @@ See :ref:`cli_vacuum`. -h, --help Show this message and exit. +.. _cli_ref_dump: + dump ==== @@ -1010,6 +1067,8 @@ See :ref:`cli_dump`. -h, --help Show this message and exit. +.. _cli_ref_add_column: + add-column ========== @@ -1036,6 +1095,8 @@ See :ref:`cli_add_column`. -h, --help Show this message and exit. +.. _cli_ref_add_foreign_key: + add-foreign-key =============== @@ -1060,6 +1121,8 @@ See :ref:`cli_add_foreign_key`. -h, --help Show this message and exit. +.. _cli_ref_add_foreign_keys: + add-foreign-keys ================ @@ -1082,6 +1145,8 @@ See :ref:`cli_add_foreign_keys`. -h, --help Show this message and exit. +.. _cli_ref_index_foreign_keys: + index-foreign-keys ================== @@ -1102,6 +1167,8 @@ See :ref:`cli_index_foreign_keys`. -h, --help Show this message and exit. +.. _cli_ref_enable_wal: + enable-wal ========== @@ -1122,6 +1189,8 @@ See :ref:`cli_wal`. -h, --help Show this message and exit. +.. _cli_ref_disable_wal: + disable-wal =========== @@ -1140,6 +1209,8 @@ disable-wal -h, --help Show this message and exit. +.. _cli_ref_enable_counts: + enable-counts ============= @@ -1160,6 +1231,8 @@ See :ref:`cli_enable_counts`. -h, --help Show this message and exit. +.. _cli_ref_reset_counts: + reset-counts ============ @@ -1178,6 +1251,8 @@ reset-counts -h, --help Show this message and exit. +.. _cli_ref_duplicate: + duplicate ========= @@ -1193,6 +1268,8 @@ duplicate -h, --help Show this message and exit. +.. _cli_ref_drop_table: + drop-table ========== @@ -1214,6 +1291,8 @@ See :ref:`cli_drop_table`. -h, --help Show this message and exit. +.. _cli_ref_create_view: + create-view =========== @@ -1237,6 +1316,8 @@ See :ref:`cli_create_view`. -h, --help Show this message and exit. +.. _cli_ref_drop_view: + drop-view ========= @@ -1258,6 +1339,8 @@ See :ref:`cli_drop_view`. -h, --help Show this message and exit. +.. _cli_ref_add_geometry_column: + add-geometry-column =================== @@ -1287,6 +1370,8 @@ See :ref:`cli_spatialite`. -h, --help Show this message and exit. +.. _cli_ref_create_spatial_index: + create-spatial-index ==================== diff --git a/docs/cli.rst b/docs/cli.rst index e3b1294..d2d1812 100644 --- a/docs/cli.rst +++ b/docs/cli.rst @@ -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 dogs.db "select * from dogs" +.. note:: + In Python: :ref:`db.query() ` CLI reference: :ref:`sqlite-utils query ` + .. _cli_query_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 [{"spatialite_version()": "4.3.0a"}] + .. _cli_query_attach: 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 \ 'select * from sqlite_master union all select * from books.sqlite_master' +.. note:: + In Python: :ref:`db.attach() ` + .. _cli_memory: Querying data directly using an in-memory database @@ -462,6 +469,9 @@ Or pass named parameters using ``--where`` in combination with ``-p``:: Use ``--limit N`` to only return the first ``N`` rows. Use ``--offset N`` to return rows starting from the specified offset. +.. note:: + In Python: :ref:`table.rows ` CLI reference: :ref:`sqlite-utils rows ` + .. _cli_tables: Listing tables @@ -514,6 +524,9 @@ Use ``--schema`` to include the schema of each table:: The ``--nl``, ``--csv``, ``--tsv``, ``--table`` and ``--fmt`` options are also available. +.. note:: + In Python: :ref:`db.tables or db.table_names() ` CLI reference: :ref:`sqlite-utils tables ` + .. _cli_views: Listing views @@ -537,6 +550,9 @@ It takes the same options as the ``tables`` command: * ``--tsv`` * ``--table`` +.. note:: + In Python: :ref:`db.views or db.view_names() ` CLI reference: :ref:`sqlite-utils views ` + .. _cli_indexes: Listing indexes @@ -564,6 +580,9 @@ The command defaults to only showing the columns that are explicitly part of the The command takes the same format options as the ``tables`` and ``views`` commands. +.. note:: + In Python: :ref:`table.indexes ` CLI reference: :ref:`sqlite-utils indexes ` + .. _cli_triggers: Listing triggers @@ -592,6 +611,9 @@ It defaults to showing triggers for all tables. To see triggers for one or more The command takes the same format options as the ``tables`` and ``views`` commands. +.. note:: + In Python: :ref:`table.triggers or db.triggers ` CLI reference: :ref:`sqlite-utils triggers ` + .. _cli_schema: Showing the schema @@ -610,6 +632,9 @@ This will show the schema for every table and index in the database. To view the $ sqlite-utils schema dogs.db dogs chickens ... +.. note:: + In Python: :ref:`table.schema ` or :ref:`db.schema ` CLI reference: :ref:`sqlite-utils schema ` + .. _cli_analyze_tables: Analyzing tables