mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-09 18:14:09 +02:00
db.attach(alias, filepath) method, closes #113
Will also be useful for #236
This commit is contained in:
parent
2c1b9f2445
commit
999f099cbe
3 changed files with 45 additions and 0 deletions
16
tests/test_attach.py
Normal file
16
tests/test_attach.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from sqlite_utils import Database
|
||||
|
||||
|
||||
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)
|
||||
assert db.execute(
|
||||
"select * from foo union all select * from bar.bar"
|
||||
).fetchall() == [(1, "foo"), (1, "bar")]
|
||||
Loading…
Add table
Add a link
Reference in a new issue