Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5778fa8

Browse files
committed
Added documentation for iterability
1 parent4b12fcd commit5778fa8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

‎docs/getting-started.rst‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ Now you can get all elements stored in the database by running:
4040
>>>db.all()
4141
[{'count': 7, 'type': 'apple'}, {'count': 3, 'type': 'peach'}]
4242

43+
You can also iter over stored elements:
44+
45+
>>>for itemin db:
46+
>>>print(item)
47+
{'count': 7, 'type': 'apple'}
48+
{'count': 3, 'type': 'peach'}
49+
4350
Of course you'll also want to search for specific elements. Let's try:
4451

4552
>>>Fruit= Query()
@@ -83,6 +90,8 @@ Before we dive deeper, let's recapitulate the basics:
8390
+-------------------------------+---------------------------------------------------------------+
8491
| ``db.all()``| Get all elements|
8592
+-------------------------------+---------------------------------------------------------------+
93+
| ``iter(db)``| Iter over all elements|
94+
+-------------------------------+---------------------------------------------------------------+
8695
| ``db.search(query)``| Get a list of elements matching the query|
8796
+-------------------------------+---------------------------------------------------------------+
8897
| **Updating**|

‎docs/usage.rst‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ the ``TinyDB`` class. To create and use a table, use ``db.table(name)``.
339339
>>>table.insert({'value':True})
340340
>>>table.all()
341341
[{'value': True}]
342+
>>>for rowin table:
343+
>>>print(row)
344+
{'value': True}
342345

343346
To remove a table from a database, use:
344347

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp