Skip to content

Commit cb75d9e

Browse files
committed
plugs the '.attach DATABASE' command into real action
1 parent 007c8fa commit cb75d9e

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

sqlite_bro/sqlite_bro.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,10 @@ def sav_script(self):
245245
f.write("/*utf-8 tag : 你好 мир Artisou à croute*/\n")
246246
f.write(script)
247247

248-
def attach_db(self):
248+
def attach_db(self, filename=''):
249249
"""attach an existing database"""
250-
filename = filedialog.askopenfilename(
250+
if filename == '':
251+
filename = filedialog.askopenfilename(
251252
initialdir=self.initialdir, defaultextension='.db',
252253
title="Choose a database to attach ",
253254
filetypes=[("default", "*.db"), ("other", "*.db*"),
@@ -702,6 +703,11 @@ def bip(c):
702703
# import FILE TABLE
703704
shell_list = shlex.split(instru) # magic standard library
704705
try:
706+
if shell_list[0] == '.attach' and len(shell_list) >= 2:
707+
db_file = shell_list[1]
708+
if (db_file+"z")[0] == "~":
709+
db_file = os.path.join(self.home , db_file[1:])
710+
self.attach_db(db_file)
705711
if shell_list[0] == '.headers' and len(shell_list) >= 2:
706712
if shell_list[1].lower() == 'off':
707713
self.default_header = False

0 commit comments

Comments
 (0)