mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-27 20:34:12 +02:00
Test and docs for using :memory: as a filename
This commit is contained in:
parent
d5e1f8ac77
commit
eb39c84a8f
2 changed files with 19 additions and 0 deletions
|
|
@ -55,6 +55,11 @@ If you want to pretty-print the output further, you can pipe it through ``python
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
You can run queries against a temporary in-memory database by passing ``:memory:`` as the filename::
|
||||||
|
|
||||||
|
$ sqlite-utils :memory: "select sqlite_version()"
|
||||||
|
[{"sqlite_version()": "3.29.0"}]
|
||||||
|
|
||||||
.. _cli_json_values:
|
.. _cli_json_values:
|
||||||
|
|
||||||
Nested JSON values
|
Nested JSON values
|
||||||
|
|
|
||||||
|
|
@ -724,6 +724,20 @@ def test_query_json_with_json_cols(db_path):
|
||||||
assert expected == result_rows.output.strip()
|
assert expected == result_rows.output.strip()
|
||||||
|
|
||||||
|
|
||||||
|
def test_query_memory_does_not_create_file(tmpdir):
|
||||||
|
owd = os.getcwd()
|
||||||
|
try:
|
||||||
|
os.chdir(tmpdir)
|
||||||
|
# This should create a foo.db file
|
||||||
|
CliRunner().invoke(cli.cli, ["foo.db", "select sqlite_version()"])
|
||||||
|
# This should NOT create a file
|
||||||
|
result = CliRunner().invoke(cli.cli, [":memory:", "select sqlite_version()"])
|
||||||
|
assert ["sqlite_version()"] == list(json.loads(result.output)[0].keys())
|
||||||
|
finally:
|
||||||
|
os.chdir(owd)
|
||||||
|
assert ["foo.db"] == os.listdir(tmpdir)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"args,expected",
|
"args,expected",
|
||||||
[
|
[
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue