Verify SQLite DBs with check_connection

pull/672/head
Simon Willison 2020-03-26 18:03:41 -07:00
rodzic ec0d68da70
commit ee718b98b7
2 zmienionych plików z 3 dodań i 2 usunięć

Wyświetl plik

@ -227,7 +227,7 @@ class Datasette:
self.databases.pop(name)
def scan_dirs(self):
# Recurse through self.dirs looking for new SQLite DBs
# Recurse through self.dirs looking for new SQLite DBs. Runs in a thread.
while True:
current_filepaths = {
d.path for d in list(self.databases.values()) if d.path is not None

Wyświetl plik

@ -603,7 +603,8 @@ def is_valid_sqlite(path):
return False
# Check we can run `select * from sqlite_master`
try:
sqlite3.connect(str(path)).execute("select * from sqlite_master")
conn = sqlite3.connect(str(path))
check_connection(conn)
except Exception:
return False
return True