Commit 26443005 authored by Manuel Mohr's avatar Manuel Mohr
Browse files

statev_sql: Cache and reuse context ids.

parent abe4f6a6
......@@ -145,14 +145,21 @@ class EmitSqlite3(EmitBase):
marks = ",".join(["?"] * len(ctxcols))
self.ctxinsert = "insert into `%s` (%s) values (%s)" % (self.ctxtab, keys, marks)
self.contextids = dict()
def ev(self, curr_id, evitems):
self.execute(self.evinsert, (curr_id,) + tuple(evitems))
def ctx(self, ctxitems):
self.execute(self.ctxinsert, tuple(ctxitems))
return self.cursor.lastrowid
items = tuple(ctxitems)
if self.contextids.has_key(items):
return self.contextids[items]
self.execute(self.ctxinsert, items)
ctxid = self.cursor.lastrowid
self.contextids[items] = ctxid
return ctxid
def commit(self):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment