Optimize sqlite transactions

This commit is contained in:
croneter 2018-12-09 13:04:27 +01:00
parent d33ba7e502
commit 80414ea0d4
2 changed files with 8 additions and 3 deletions

View file

@ -72,7 +72,9 @@ class ItemBase(object):
if exc_type:
# re-raise any exception
return False
self.commit()
self.plexconn.commit()
self.artconn.commit()
self.kodiconn.commit()
self.plexconn.close()
self.kodiconn.close()
self.artconn.close()
@ -80,8 +82,11 @@ class ItemBase(object):
def commit(self):
self.plexconn.commit()
self.plexconn.execute('BEGIN')
self.artconn.commit()
self.artconn.execute('BEGIN')
self.kodiconn.commit()
self.kodiconn.execute('BEGIN')
def set_fanart(self, artworks, kodi_id, kodi_type):
"""

View file

@ -403,10 +403,10 @@ def kodi_sql(media_type=None):
else:
db_path = v.DB_VIDEO_PATH
conn = connect(db_path, timeout=5.0)
conn.execute('PRAGMA journal_mode=WAL')
conn.execute('PRAGMA journal_mode=WAL;')
conn.execute('PRAGMA synchronous=NORMAL;')
# Use transactions
conn.execute('BEGIN;')
conn.execute('BEGIN')
return conn