mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 09:24:31 +02:00
Improved .rows_where() documentation, added test for :named parameters
This commit is contained in:
parent
670f92285f
commit
2dad4f583c
2 changed files with 8 additions and 1 deletions
|
|
@ -202,7 +202,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=``::
|
||||
The first argument is a fragment of SQL. The second, optional argument is values to be passed to that fragment - you can use ``?`` placeholders and pass an array, or you can use ``:named`` parameters and pass a dictionary, like this::
|
||||
|
||||
>>> for row in db["dogs"].rows_where("age > :age", {"age": 3}):
|
||||
... print(row)
|
||||
{'id': 1, 'age': 4, 'name': 'Cleo'}
|
||||
|
||||
To return custom columns (instead of the default that uses ``select *``) pass ``select="column1, column2"``::
|
||||
|
||||
>>> db = sqlite_utils.Database("dogs.db")
|
||||
>>> for row in db["dogs"].rows_where(select='name, age'):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue