1- #V1.00 .00
1+ #V1.01 .00
22
33#Importing libraries
44import os
@@ -53,15 +53,15 @@ def ConvertDB(dbFile, savePath):
5353 subConvertDB (path_f , dbFile , tableName )
5454 count += 1
5555
56- #Opens a dialogue to select a .DB file from Windows explorer
56+ #Opens a dialogue to select an SQLite3 Database file from Windows explorer
5757def openFile ():
5858 global filePath # Setting filePath as global variable for use elsewhere
59- filePath = filedialog .askopenfilename (title = "Open an SQLite3 Database file (*.DB Format) " ,
60- filetypes = (("SQLite3 Database File" , "*.db" ), ("all files" , "*.*" )))
59+ filePath = filedialog .askopenfilename (title = "Open an SQLite3 Database file" ,
60+ filetypes = (("SQLite3 Database File" , tuple ( extensionsAllowable ) ), ("all files" , "*.*" )))
6161 my_text .configure (state = "normal" )
6262 my_text .delete (1.0 , END ) # Clearing existing input
6363
64- if filePath .endswith (".DB" ) or filePath . endswith ( ".db" ):
64+ if filePath .endswith (tuple ( extensionsAllowable ) ):
6565 my_text .insert (END , filePath ) #Adding new input to text box
6666
6767 con = sqlite3 .connect (filePath )
@@ -109,9 +109,9 @@ def saveLocation():
109109def ConversionWindow ():
110110 errorOutput .configure (text = "" )
111111
112- if outputPath and (filePath .endswith (".DB" ) or filePath . endswith ( ".db" )):
112+ if outputPath and (filePath .endswith (tuple ( extensionsAllowable ) )):
113113 ConvertDB (filePath , outputPath )
114- errorOutput .configure (text = "The database has been successfully converted into CSV files !" ,
114+ errorOutput .configure (text = "The selected SQLite3 database table(s) have been successfully converted into CSV file(s) !" ,
115115 fg = 'Dark Green' )
116116 cancelButton .configure (text = "Exit" )
117117 else :
@@ -128,6 +128,7 @@ def readStates():
128128 tickStates = []
129129 tickStates = [var .get () for var in checkbox_vars ]
130130
131+ extensionsAllowable = [".DB" , ".db" , ".db3" , ".sqlite" , ".sqlite3" ] #List of common SQLite3 file extensions
131132
132133#Setting global variables to false in case of immediate exit of file selection
133134filePath = FALSE
@@ -150,13 +151,13 @@ def readStates():
150151#Basic window geometry
151152mainWindow .geometry ('%dx%d+%d+%d' % (windowWidth , windowHeight , windowCornerH , windowCornerV ))
152153mainWindow .resizable (False , False )
153- mainWindow .title ("SQLite3 Database (*.DB) Conversion Tool" )
154+ mainWindow .title ("SQLite3 Database Conversion Tool" )
154155
155156#Labels and buttons for the input file selection
156- winLabelIn = Label (mainWindow , text = "Press the button below to select an SQLite3 database file (*.DB) " )
157+ winLabelIn = Label (mainWindow , text = "Press the button below to select an SQLite3 database file" )
157158my_text = Text (mainWindow , width = 135 , height = 1 )
158159my_text .configure (state = "disabled" )
159- buttonIn = Button (text = "Open File (.DB) " ,command = openFile )
160+ buttonIn = Button (text = "Open Database " ,command = openFile )
160161
161162#Labels and buttons for the output directory selection
162163winLabelOut = Label (mainWindow , text = "Press the button below to select a directory to save the *.csv outputs to" )
0 commit comments