mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 01:44:31 +02:00
table.create_index(columns, index_name) method
This commit is contained in:
parent
70e1f831a0
commit
4427d2d96f
3 changed files with 81 additions and 0 deletions
|
|
@ -204,3 +204,21 @@ If you insert additional records into the table you will need to refresh the sea
|
|||
"is_good_dog": True,
|
||||
}, pk="id")
|
||||
dogs.populate_fts(["name", "twitter"])
|
||||
|
||||
Creating indexes
|
||||
================
|
||||
|
||||
You can create an index on a table using the ``.create_index(columns)`` method. The method takes a list of columns:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
dogs.create_index(["is_good_dog"])
|
||||
|
||||
By default the index will be named ``idx_{table-name}_{columns}`` - if you want to customize the name of the created index you can pass the ``index_name`` parameter::]
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
dogs.create_index(
|
||||
["is_good_dog", "age"],
|
||||
index_name="good_dogs_by_age"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue