mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Verify SQLite DBs with check_connection
This commit is contained in:
parent
ec0d68da70
commit
ee718b98b7
2 changed files with 3 additions and 2 deletions
|
|
@ -227,7 +227,7 @@ class Datasette:
|
||||||
self.databases.pop(name)
|
self.databases.pop(name)
|
||||||
|
|
||||||
def scan_dirs(self):
|
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:
|
while True:
|
||||||
current_filepaths = {
|
current_filepaths = {
|
||||||
d.path for d in list(self.databases.values()) if d.path is not None
|
d.path for d in list(self.databases.values()) if d.path is not None
|
||||||
|
|
|
||||||
|
|
@ -603,7 +603,8 @@ def is_valid_sqlite(path):
|
||||||
return False
|
return False
|
||||||
# Check we can run `select * from sqlite_master`
|
# Check we can run `select * from sqlite_master`
|
||||||
try:
|
try:
|
||||||
sqlite3.connect(str(path)).execute("select * from sqlite_master")
|
conn = sqlite3.connect(str(path))
|
||||||
|
check_connection(conn)
|
||||||
except Exception:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue