Merge pull request #339 from drzoidberg33/security-fixes
Move dict_factory out of database class.
This commit is contained in:
@@ -46,6 +46,13 @@ def get_cache_size():
|
||||
return 0
|
||||
return int(plexpy.CONFIG.CACHE_SIZEMB)
|
||||
|
||||
def dict_factory(cursor, row):
|
||||
d = {}
|
||||
for idx, col in enumerate(cursor.description):
|
||||
d[col[0]] = row[idx]
|
||||
|
||||
return d
|
||||
|
||||
|
||||
class MonitorDatabase(object):
|
||||
|
||||
@@ -58,14 +65,7 @@ class MonitorDatabase(object):
|
||||
self.connection.execute("PRAGMA journal_mode = %s" % plexpy.CONFIG.JOURNAL_MODE)
|
||||
# 64mb of cache memory, probably need to make it user configurable
|
||||
self.connection.execute("PRAGMA cache_size=-%s" % (get_cache_size() * 1024))
|
||||
self.connection.row_factory = self.dict_factory
|
||||
|
||||
def dict_factory(self, cursor, row):
|
||||
d = {}
|
||||
for idx, col in enumerate(cursor.description):
|
||||
d[col[0]] = row[idx]
|
||||
|
||||
return d
|
||||
self.connection.row_factory = dict_factory
|
||||
|
||||
def action(self, query, args=None, return_last_id=False):
|
||||
if query is None:
|
||||
|
Reference in New Issue
Block a user