mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
New .rows_where(select=) argument
This commit is contained in:
parent
317071a552
commit
71782311ce
3 changed files with 11 additions and 4 deletions
|
|
@ -145,7 +145,7 @@ View objects are similar to Table objects, except that any attempts to insert or
|
|||
* ``count``
|
||||
* ``schema``
|
||||
* ``rows``
|
||||
* ``rows_where(where, where_args, order_by)``
|
||||
* ``rows_where(where, where_args, order_by, select)``
|
||||
* ``drop()``
|
||||
|
||||
.. _python_api_rows:
|
||||
|
|
@ -168,6 +168,13 @@ You can filter rows by a WHERE clause using ``.rows_where(where, where_args)``::
|
|||
... print(row)
|
||||
{'id': 1, 'age': 4, 'name': 'Cleo'}
|
||||
|
||||
To return custom columns (instead of using ``select *``) pass ``select=``::
|
||||
|
||||
>>> db = sqlite_utils.Database("dogs.db")
|
||||
>>> for row in db["dogs"].rows_where(select='name, age'):
|
||||
... print(row)
|
||||
{'name': 'Cleo', 'age': 4}
|
||||
|
||||
To specify an order, use the ``order_by=`` argument::
|
||||
|
||||
>>> for row in db["dogs"].rows_where("age > 1", order_by="age"):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue