Better handling of corrupted database files

pull/546/merge
Simon Willison 2019-12-22 15:31:40 +00:00
rodzic d6b6c9171f
commit 16665c9ee6
1 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

@ -97,7 +97,7 @@ class Database:
else:
rows = cursor.fetchall()
truncated = False
except sqlite3.OperationalError as e:
except (sqlite3.OperationalError, sqlite3.DatabaseError) as e:
if e.args == ("interrupted",):
raise QueryInterrupted(e, sql, params)
if log_sql_errors:
@ -145,7 +145,7 @@ class Database:
counts[table] = table_count
# In some cases I saw "SQL Logic Error" here in addition to
# QueryInterrupted - so we catch that too:
except (QueryInterrupted, sqlite3.OperationalError):
except (QueryInterrupted, sqlite3.OperationalError, sqlite3.DatabaseError):
counts[table] = None
if not self.is_mutable:
self.cached_table_counts = counts