Properly pass the cache size when initializing a db connection

This commit is contained in:
rembo10
2012-10-08 21:34:02 +01:00
parent 49831dd467
commit 7f56277c40

View File

@@ -33,6 +33,9 @@ db_lock = threading.Lock()
def dbFilename(filename="headphones.db"):
return os.path.join(headphones.DATA_DIR, filename)
def getCacheSize():
return int(headphones.CACHE_SIZEMB)
class DBConnection:
@@ -45,7 +48,7 @@ class DBConnection:
#journal disabled since we never do rollbacks
self.connection.execute("PRAGMA journal_mode = OFF")
#64mb of cache memory,probably need to make it user configurable
self.connection.execute("PRAGMA cache_size=-%s" % (headphones.CACHE_SIZEMB*1024))
self.connection.execute("PRAGMA cache_size=-%s" % (getCacheSize()*1024))
self.connection.row_factory = sqlite3.Row
def action(self, query, args=None):