mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 18:04:32 +02:00
parent
d302835d57
commit
7a52214624
8 changed files with 137 additions and 1 deletions
|
|
@ -12,6 +12,7 @@ Unreleased
|
|||
- ``sqlite-utils query`` can now read the SQL query from standard input by passing ``-`` in place of the query, for example ``echo "select * from dogs" | sqlite-utils query dogs.db -``. (:issue:`765`)
|
||||
- ``sqlite-utils insert`` and ``sqlite-utils upsert`` now accept a ``--code`` option for :ref:`providing a block of Python code <cli_insert_code>` (or a path to a ``.py`` file) that defines a ``rows()`` function or ``rows`` iterable of rows to insert, as an alternative to importing from a file. (:issue:`684`)
|
||||
- ``sqlite-utils insert`` and ``sqlite-utils upsert`` now accept ``--type column-name type`` to :ref:`override the type automatically chosen when the table is created <cli_insert_csv_tsv_column_types>`. This is useful for CSV or TSV columns such as ZIP codes that look like integers but should be stored as ``TEXT`` to preserve leading zeros. (:issue:`131`)
|
||||
- New ``table.drop_index(name)`` method and ``sqlite-utils drop-index`` command for dropping an index by name. Both accept ``ignore=True``/``--ignore`` to ignore a missing index. (:issue:`626`)
|
||||
|
||||
.. _v4_0:
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ This page lists the ``--help`` for every ``sqlite-utils`` CLI sub-command.
|
|||
go_first = [
|
||||
"query", "memory", "insert", "upsert", "bulk", "search", "transform", "extract",
|
||||
"schema", "insert-files", "analyze-tables", "convert", "tables", "views", "rows",
|
||||
"triggers", "indexes", "create-database", "create-table", "create-index",
|
||||
"triggers", "indexes", "create-database", "create-table", "create-index", "drop-index",
|
||||
"migrate", "enable-fts", "populate-fts", "rebuild-fts", "disable-fts"
|
||||
]
|
||||
refs = {
|
||||
|
|
@ -46,6 +46,7 @@ This page lists the ``--help`` for every ``sqlite-utils`` CLI sub-command.
|
|||
"add-foreign-keys": "cli_add_foreign_keys",
|
||||
"index-foreign-keys": "cli_index_foreign_keys",
|
||||
"create-index": "cli_create_index",
|
||||
"drop-index": "cli_drop_index",
|
||||
"enable-wal": "cli_wal",
|
||||
"enable-counts": "cli_enable_counts",
|
||||
"bulk": "cli_bulk",
|
||||
|
|
@ -1006,6 +1007,29 @@ See :ref:`cli_create_index`.
|
|||
-h, --help Show this message and exit.
|
||||
|
||||
|
||||
.. _cli_ref_drop_index:
|
||||
|
||||
drop-index
|
||||
==========
|
||||
|
||||
See :ref:`cli_drop_index`.
|
||||
|
||||
::
|
||||
|
||||
Usage: sqlite-utils drop-index [OPTIONS] PATH TABLE INDEX
|
||||
|
||||
Drop an index by index name from the specified table
|
||||
|
||||
Example:
|
||||
|
||||
sqlite-utils drop-index chickens.db chickens idx_chickens_name
|
||||
|
||||
Options:
|
||||
--ignore Ignore if index does not exist
|
||||
--load-extension TEXT Path to SQLite extension, with optional :entrypoint
|
||||
-h, --help Show this message and exit.
|
||||
|
||||
|
||||
.. _cli_ref_migrate:
|
||||
|
||||
migrate
|
||||
|
|
|
|||
13
docs/cli.rst
13
docs/cli.rst
|
|
@ -2615,6 +2615,19 @@ If your column names are already prefixed with a hyphen you'll need to manually
|
|||
|
||||
Add the ``--analyze`` option to run ``ANALYZE`` against the index after it has been created.
|
||||
|
||||
.. _cli_drop_index:
|
||||
|
||||
Dropping indexes
|
||||
================
|
||||
|
||||
You can drop an index from an existing table using the ``drop-index`` command:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sqlite-utils drop-index mydb.db mytable idx_mytable_col1
|
||||
|
||||
Use ``--ignore`` to ignore the error if the index does not exist on that table.
|
||||
|
||||
.. _cli_fts:
|
||||
|
||||
Configuring full-text search
|
||||
|
|
|
|||
|
|
@ -2877,6 +2877,14 @@ Use ``if_not_exists=True`` to do nothing if an index with that name already exis
|
|||
|
||||
Pass ``analyze=True`` to run ``ANALYZE`` against the new index after creating it.
|
||||
|
||||
You can drop an index from a table using ``.drop_index(index_name)``:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
db.table("dogs").drop_index("idx_dogs_name")
|
||||
|
||||
Use ``ignore=True`` to ignore the error if the index does not exist.
|
||||
|
||||
.. _python_api_analyze:
|
||||
|
||||
Optimizing index usage with ANALYZE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue