I am using sqlite3 in python. Currently I am using this following code
try:
con = sqlite3.connect(filename)
cur = con.cursor()
# run a fake query to test if the file selected is really a database
cur.execute("SELECT DISTINCT id FROM handle ORDER BY id DESC")
except:
eel.invalidFile()
else:
ExamineTable.printPhoneNum(con)
and it works fine. I am running a fake query to test for a real database, because I found that without this line users could select files that aren't databases and no exception would be thrown when sqlite3 tries to connect. Which might be by design, but I'm wondering if there's a more formal way of checking without running a dummy query?