def _flush(self, save_all=False):
curr_tab = self.current_table
tables = self.get_all_tables() if save_all else [curr_tab]
for tab in tables:
self.set_table(tab)
if len(self.current_cache) > 0:
self.cursor.executemany(
"INSERT INTO {tb} VALUES (?, ?)".format(tb=tab),
[(str(k), marshal.dumps(v.tolist()) if isinstance(v, np.ndarray)
else marshal.dumps(v))
for k, v in self.current_cache.items()])
self.connection.commit()
self.current_cache.clear()
# restore the last table
return self.set_table(curr_tab)
评论列表
文章目录