mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-08-03 07:54:22 +02:00
sqlite-utils --attach option, closes #236
This commit is contained in:
parent
999f099cbe
commit
2ba5588881
4 changed files with 49 additions and 2 deletions
|
|
@ -1855,3 +1855,25 @@ def test_csv_import_no_headers(tmpdir, args):
|
|||
{"untitled_1": "Cleo", "untitled_2": "Dog", "untitled_3": "5"},
|
||||
{"untitled_1": "Tracy", "untitled_2": "Spider", "untitled_3": "7"},
|
||||
]
|
||||
|
||||
|
||||
def test_attach(tmpdir):
|
||||
foo_path = str(tmpdir / "foo.db")
|
||||
bar_path = str(tmpdir / "bar.db")
|
||||
db = Database(foo_path)
|
||||
with db.conn:
|
||||
db["foo"].insert({"id": 1, "text": "foo"})
|
||||
db2 = Database(bar_path)
|
||||
with db2.conn:
|
||||
db2["bar"].insert({"id": 1, "text": "bar"})
|
||||
db.attach("bar", bar_path)
|
||||
sql = "select * from foo union all select * from bar.bar"
|
||||
result = CliRunner().invoke(
|
||||
cli.cli,
|
||||
[foo_path, "--attach", "bar", bar_path, sql],
|
||||
catch_exceptions=False,
|
||||
)
|
||||
assert json.loads(result.output) == [
|
||||
{"id": 1, "text": "foo"},
|
||||
{"id": 1, "text": "bar"},
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue