sqlite-utils rows --where and -p options, closes #382

This commit is contained in:
Simon Willison 2022-01-11 15:32:43 -08:00
commit 3b632f0a7e
4 changed files with 57 additions and 18 deletions

View file

@ -851,6 +851,7 @@ def test_query_memory_does_not_create_file(tmpdir):
["--nl", "-c", "age", "-c", "name"],
'{"age": 4, "name": "Cleo"}\n{"age": 2, "name": "Pancakes"}',
),
# --limit and --offset
(
["-c", "name", "--limit", "1"],
'[{"name": "Cleo"}]',
@ -859,6 +860,19 @@ def test_query_memory_does_not_create_file(tmpdir):
["-c", "name", "--limit", "1", "--offset", "1"],
'[{"name": "Pancakes"}]',
),
# --where
(
["-c", "name", "--where", "id = 1"],
'[{"name": "Cleo"}]',
),
(
["-c", "name", "--where", "id = :id", "-p", "id", "1"],
'[{"name": "Cleo"}]',
),
(
["-c", "name", "--where", "id = :id", "--param", "id", "1"],
'[{"name": "Cleo"}]',
),
],
)
def test_rows(db_path, args, expected):