mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-18 14:34:24 +02:00
DescIndex(column) for descending index columns, refs #260
This commit is contained in:
parent
b2302875c9
commit
c374d7ef04
3 changed files with 37 additions and 1 deletions
|
|
@ -1866,6 +1866,17 @@ By default the index will be named ``idx_{table-name}_{columns}`` - if you want
|
|||
index_name="good_dogs_by_age"
|
||||
)
|
||||
|
||||
To create an index in descending order for a column, wrap the column name in ``db.DescIndex()`` like this:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from sqlite_utils.db import DescIndex
|
||||
|
||||
db["dogs"].create_index(
|
||||
["is_good_dog", DescIndex("age")],
|
||||
index_name="good_dogs_by_age"
|
||||
)
|
||||
|
||||
You can create a unique index by passing ``unique=True``:
|
||||
|
||||
.. code-block:: python
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue