Optimize sqlite transactions
This commit is contained in:
parent
d33ba7e502
commit
80414ea0d4
2 changed files with 8 additions and 3 deletions
|
@ -72,7 +72,9 @@ class ItemBase(object):
|
||||||
if exc_type:
|
if exc_type:
|
||||||
# re-raise any exception
|
# re-raise any exception
|
||||||
return False
|
return False
|
||||||
self.commit()
|
self.plexconn.commit()
|
||||||
|
self.artconn.commit()
|
||||||
|
self.kodiconn.commit()
|
||||||
self.plexconn.close()
|
self.plexconn.close()
|
||||||
self.kodiconn.close()
|
self.kodiconn.close()
|
||||||
self.artconn.close()
|
self.artconn.close()
|
||||||
|
@ -80,8 +82,11 @@ class ItemBase(object):
|
||||||
|
|
||||||
def commit(self):
|
def commit(self):
|
||||||
self.plexconn.commit()
|
self.plexconn.commit()
|
||||||
|
self.plexconn.execute('BEGIN')
|
||||||
self.artconn.commit()
|
self.artconn.commit()
|
||||||
|
self.artconn.execute('BEGIN')
|
||||||
self.kodiconn.commit()
|
self.kodiconn.commit()
|
||||||
|
self.kodiconn.execute('BEGIN')
|
||||||
|
|
||||||
def set_fanart(self, artworks, kodi_id, kodi_type):
|
def set_fanart(self, artworks, kodi_id, kodi_type):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -403,10 +403,10 @@ def kodi_sql(media_type=None):
|
||||||
else:
|
else:
|
||||||
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 synchronous=NORMAL;')
|
conn.execute('PRAGMA synchronous=NORMAL;')
|
||||||
# Use transactions
|
# Use transactions
|
||||||
conn.execute('BEGIN;')
|
conn.execute('BEGIN')
|
||||||
return conn
|
return conn
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue