Ignore operational error when optimize SQLite database on connection
The 'PRAGMA optimize' command can not run on a locked database which may happen when a nested transaction is started. Closes #13793
This commit is contained in:
@@ -525,7 +525,11 @@ class Database(DatabaseInterface):
|
||||
self._conn.execute('PRAGMA foreign_keys = ON')
|
||||
self._conn.execute('PRAGMA journal_mode = WAL')
|
||||
self._conn.execute('PRAGMA synchronous = NORMAL')
|
||||
self._conn.execute('PRAGMA optimize')
|
||||
try:
|
||||
self._conn.execute('PRAGMA optimize')
|
||||
except DatabaseOperationalError:
|
||||
# database may be locked
|
||||
pass
|
||||
return self
|
||||
|
||||
def _make_uri(self):
|
||||
|
||||
Reference in New Issue
Block a user