New method for DB commit

This commit is contained in:
croneter 2018-11-11 09:23:51 +01:00
parent 6de47490c3
commit afedf03ac9
3 changed files with 8 additions and 6 deletions

View file

@ -70,14 +70,17 @@ class ItemBase(object):
""" """
Make sure DB changes are committed and connection to DB is closed. Make sure DB changes are committed and connection to DB is closed.
""" """
self.plexconn.commit() self.commit()
self.kodiconn.commit()
self.artconn.commit()
self.plexconn.close() self.plexconn.close()
self.kodiconn.close() self.kodiconn.close()
self.artconn.close() self.artconn.close()
return self return self
def commit(self):
self.plexconn.commit()
self.artconn.commit()
self.kodiconn.commit()
def set_fanart(self, artworks, kodi_id, kodi_type): def set_fanart(self, artworks, kodi_id, kodi_type):
""" """
Writes artworks [dict containing only set artworks] to the Kodi art DB Writes artworks [dict containing only set artworks] to the Kodi art DB

View file

@ -125,9 +125,7 @@ class ProcessMetadata(backgroundthread.KillableThread, common.libsync_mixin):
self.current += 1 self.current += 1
if self.processed == 500: if self.processed == 500:
self.processed = 0 self.processed = 0
context.kodiconn.commit() context.commit()
context.artconn.commit()
context.plexconn.commit()
self.queue.task_done() self.queue.task_done()
profile.disable() profile.disable()
string_io = StringIO() string_io = StringIO()

View file

@ -490,6 +490,7 @@ def kodi_sql(media_type=None):
db_path = v.DB_VIDEO_PATH db_path = v.DB_VIDEO_PATH
conn = connect(db_path, timeout=5.0) conn = connect(db_path, timeout=5.0)
conn.execute('PRAGMA journal_mode=WAL') conn.execute('PRAGMA journal_mode=WAL')
conn.execute('PRAGMA wal_autocheckpoint=500;')
return conn return conn