Skip to content

Commit dd2f2a3

Browse files
V1.03.00
1 parent 7dc7d39 commit dd2f2a3

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

DBConverter.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
###################
2-
# VERSION 1.02.01 #
2+
# VERSION 1.03.00 #
33
###################
44

55
###################
@@ -85,13 +85,22 @@ def openFile():
8585
mainTextInput.configure(state="normal")
8686
mainTextInput.delete(1.0, END)
8787

88-
#IF EXTENSION VALID QUERY TABLE AND CREATE CHECKLIST OF DATABASE TABLES. IF INVALID CLEAR CHECKLIST.
89-
if filePath.endswith(tuple(extensionsAllowable)):
88+
con = sqlite3.connect(filePath)
89+
cur = con.cursor()
9090

91-
mainTextInput.insert(END, filePath)
91+
#CHECKS VALIDITY OF SELECTED DATABASE
92+
validDatabase = True
93+
try:
94+
cur.execute("PRAGMA schema_version")
95+
except sqlite3.DatabaseError as e:
96+
validDatabase = False
97+
mainLabelError.configure(text="Selected file is not a valid SQLite3 database.", fg='red')
9298

93-
con = sqlite3.connect(filePath)
94-
cur = con.cursor()
99+
#IF VALID SQLITE3 DATABASE QUERY TABLE AND CREATE CHECKLIST OF DATABASE TABLES. IF INVALID CLEAR CHECKLIST.
100+
if validDatabase:
101+
102+
mainLabelError.configure(text="")
103+
mainTextInput.insert(END, filePath)
95104

96105
#QUERYING DATABASE
97106
cur.execute("SELECT name FROM sqlite_master WHERE type='table'")
@@ -144,7 +153,7 @@ def saveLocation():
144153
def conversionWindow():
145154
mainLabelError.configure(text="")
146155

147-
if outputPath and (filePath.endswith(tuple(extensionsAllowable))):
156+
if outputPath and filePath:
148157
ConvertDB(filePath, outputPath)
149158
mainLabelError.configure(text="The selected SQLite3 database table(s) have been successfully converted into CSV file(s)!",
150159
fg='Dark Green')
@@ -212,6 +221,7 @@ def createScrollableContainer():
212221
checkCornerY = mainCornerY
213222

214223

224+
215225
#############
216226
# MAIN MENU #
217227
#############
@@ -221,6 +231,8 @@ def createScrollableContainer():
221231
mainWindow.geometry('%dx%d+%d+%d' % (mainWidth, mainHeight, mainCornerX, mainCornerY))
222232
mainWindow.resizable(False, False)
223233
mainWindow.title("SQLite3 Database Conversion Tool")
234+
icon = PhotoImage(file="Icon.png")
235+
mainWindow.iconphoto(False, icon)
224236

225237
#DATABASE SELECTION WIDGETS
226238
mainLabelInput = Label(mainWindow, text="Press the button below to select an SQLite3 database file")
@@ -262,7 +274,8 @@ def createScrollableContainer():
262274
checkWindow.title("Select tables to export")
263275
checkWindow.geometry('%dx%d+%d+%d' % (checkWidth, checkHeight, checkCornerX, checkCornerY))
264276
checkWindow.resizable(False, False)
265-
checkWindow.protocol("WM_DELETE_WINDOW", cancelProcess) #Closes main window when child window is closed
277+
checkWindow.iconphoto(False, icon)
278+
checkWindow.protocol("WM_DELETE_WINDOW", cancelProcess)
266279

267280
#WINDOW AND SCROLLBAR CONFIGURATION
268281
checkContainer = Canvas(checkWindow)
@@ -282,4 +295,4 @@ def createScrollableContainer():
282295

283296
createScrollableContainer()
284297
checkWindow.mainloop()
285-
mainWindow.mainloop()
298+
mainWindow.mainloop()

0 commit comments

Comments
 (0)