mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-26 19:04:32 +02:00
Documentation for .get()
This commit is contained in:
parent
1445a8ecb5
commit
b5a5df6d0e
1 changed files with 15 additions and 0 deletions
|
|
@ -72,6 +72,21 @@ You can filter rows by a WHERE clause using ``.rows_where(where, where_args)``::
|
|||
... print(row)
|
||||
{'id': 1, 'age': 4, 'name': 'Cleo'}
|
||||
|
||||
.. _python_api_get:
|
||||
|
||||
Retrieving a specific record
|
||||
============================
|
||||
|
||||
You can retrieve a record by its primary key using ``table.get()``::
|
||||
|
||||
>>> db = sqlite_utils.Database("dogs.db")
|
||||
>>> print(db["dogs"].get(1))
|
||||
{'id': 1, 'age': 4, 'name': 'Cleo'}
|
||||
|
||||
If the table has a compound primary key you can pass in the primary key values as a tuple::
|
||||
|
||||
>>> db["compound_dogs"].get(("mixed", 3))
|
||||
|
||||
Creating tables
|
||||
===============
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue