mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 17:34:32 +02:00
17 lines
654 B
Python
17 lines
654 B
Python
|
|
import types
|
||
|
|
|
||
|
|
|
||
|
|
def test_query(fresh_db):
|
||
|
|
fresh_db["dogs"].insert_all([{"name": "Cleo"}, {"name": "Pancakes"}])
|
||
|
|
results = fresh_db.query("select * from dogs order by name desc")
|
||
|
|
assert isinstance(results, types.GeneratorType)
|
||
|
|
assert list(results) == [{"name": "Pancakes"}, {"name": "Cleo"}]
|
||
|
|
|
||
|
|
|
||
|
|
def test_execute_returning_dicts(fresh_db):
|
||
|
|
# Like db.query() but returns a list, included for backwards compatibility
|
||
|
|
# see https://github.com/simonw/sqlite-utils/issues/290
|
||
|
|
fresh_db["test"].insert({"id": 1, "bar": 2}, pk="id")
|
||
|
|
assert fresh_db.execute_returning_dicts("select * from test") == [
|
||
|
|
{"id": 1, "bar": 2}
|
||
|
|
]
|