utils.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:odin 作者: imito 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号