mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
Implemented .convert(..., where=, where_args=), refs #304
This commit is contained in:
parent
4823aff4c3
commit
69c7da5ec9
3 changed files with 55 additions and 4 deletions
|
|
@ -785,6 +785,14 @@ You can create multiple new columns from a single input column by passing ``mult
|
|||
"title", lambda v: {"upper": v.upper(), "lower": v.lower()}, multi=True
|
||||
)
|
||||
|
||||
The ``.convert()`` method accepts optional ``where=`` and ``where_args=`` parameters which can be used to apply the conversion to a subset of rows specified by a where clause. Here's how to apply the conversion only to rows with an ``id`` that is higher than 20:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
table.convert("title", lambda v: v.upper(), where="id > :id", where_args={"id": 20})
|
||||
|
||||
These behave the same as the corresponding parameters to the :ref:`.rows_where() <python_api_rows>` method, so you can use ``?`` placeholders and a list of values instead of ``:named`` placeholders with a dictionary.
|
||||
|
||||
.. _python_api_lookup_tables:
|
||||
|
||||
Working with lookup tables
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue