@@ -31,11 +31,9 @@ import bisect
# after a series of INSERT, SELECT, but before a CREATE TABLE or PRAGMA.
# 3: at the end of an explicit transaction, e.g. "with self.con as con:"
#
# To speed up testing, or if this transaction speed becomes an issue,
# the sync=False option to NilmDB.__init__ will set PRAGMA synchronous=OFF.
# Don't touch old entries -- just add new ones.
# To speed things up, we can set 'PRAGMA synchronous=OFF'. Or, it
# seems that 'PRAGMA synchronous=NORMAL' and 'PRAGMA journal_mode=WAL'
# give an equivalent speedup more safely. That is what is used here.
_sql_schema_updates = {
0: """
-- All streams
@@ -77,7 +75,7 @@ _sql_schema_updates = {
class NilmDB(object):
verbose = 0
def __init__(self, basepath, sync=True, max_results=None,
def __init__(self, basepath, max_results=None,
bulkdata_args=None):
if bulkdata_args is None:
bulkdata_args = {}
@@ -101,10 +99,8 @@ class NilmDB(object):
self._sql_schema_update()
# See big comment at top about the performance implications of this
if sync:
self.con.execute("PRAGMA synchronous=FULL")
else:
self.con.execute("PRAGMA synchronous=OFF")
self.con.execute("PRAGMA synchronous=NORMAL")
self.con.execute("PRAGMA journal_mode=WAL")
# Approximate largest number of elements that we want to send
# in a single reply (for stream_intervals, stream_extract)