Skip to content

Commit 7a3e796

Browse files
committed
Post TR2 Attempt 5
1 parent 5bb5ae4 commit 7a3e796

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

tinydb/create_db.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
with TinyDB("countries.json", indent=4) as countries_db:
66
countries_table = countries_db.table(name="countries")
77

8-
countries_table.insert(
9-
{"location": "Vatican City", "population": 501}
10-
)
8+
countries_table.insert({"location": "Vatican City", "population": 501})
119

1210
countries_table.insert_multiple(
1311
[
@@ -21,4 +19,4 @@
2119

2220
for row in reader:
2321
row["population"] = int(row["population"])
24-
countries_table.insert(row)
22+
countries_table.insert(row)

tinydb/read.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@
77
countries_db = TinyDB("ten_countries.json")
88
countries_table = countries_db.table(name="countries")
99
query = Query()
10-
query_def = (query.population > 220_000_000) & (
11-
query.population < 250_000_000
12-
)
10+
query_def = (query.population > 220_000_000) & (query.population < 250_000_000)
1311
pprint(countries_table.search(query_def))
1412
pprint(countries_table.search(query_def))
1513
pprint(countries_table.search(query["% of world"] >= 17))
1614
pprint(countries_table.get(doc_ids=[9, 10]))
17-
countries_db.close()
15+
countries_db.close()

tinydb/update_db_v3.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
with TinyDB("ten_countries.json") as countries_db:
44
countries_table = countries_db.table(name="countries")
5-
countries_table.update(
6-
{"source": "Official estimate"}, doc_ids=[7, 9]
7-
)
5+
countries_table.update({"source": "Official estimate"}, doc_ids=[7, 9])

0 commit comments

Comments
 (0)