mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-25 02:14:31 +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
|
|
@ -219,6 +219,14 @@ class Database:
|
|||
def register_fts4_bm25(self):
|
||||
self.register_function(rank_bm25, deterministic=True)
|
||||
|
||||
def attach(self, alias, filepath):
|
||||
attach_sql = """
|
||||
ATTACH DATABASE '{}' AS [{}];
|
||||
""".format(
|
||||
str(pathlib.Path(filepath).resolve()), alias
|
||||
).strip()
|
||||
self.execute(attach_sql)
|
||||
|
||||
def execute(self, sql, parameters=None):
|
||||
if self._tracer:
|
||||
self._tracer(sql, parameters)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue