def add_lines(self, host, name, iterable): tablename = self._tablename(host, name) if not _exists_table(tablename): self._init_table(host, name) l_ss = [ db_common.setstate("datetime", "datetime"), db_common.setstate("value", "value") ] sql = self.db.insert_sql(tablename, l_ss) l_args = [{"datetime": dt, "value": val} for dt, val in iterable] self.db.executemany(sql, l_args)
def _init_area(self): # ported from amulog db... if self.areafn is None or self.areafn == "": return areadict = config.GroupDef(self.areafn) table_name = "area" l_ss = [ db_common.setstate("host", "host"), db_common.setstate("area", "area") ] sql = self.db.insert_sql(table_name, l_ss) for area, host in areadict.iter_def(): args = {"host": host, "area": area} self.db.execute(sql, args) self.commit()
def _add_catalog(self, host, name): if not _exists_table("catalog"): self._init_catalog() l_ss = [ db_common.setstate("tablename", "tablename"), db_common.setstate("host", "host"), db_common.setstate("name", "name") ] sql = self.db.insert_sql("catalog", l_ss) args = { "tablename": self._tablename(host, name), "host": host, "name": name } self.db.execute(sql, args)
def add_line(self, dt, gid, host): table_name = "ts" d_val = { "dt": self.db.strftime(dt), "gid": gid, "host": host, } l_ss = [db_common.setstate(k, k) for k in d_val.keys()] sql = self.db.insert_sql(table_name, l_ss) self.db.execute(sql, d_val)
def add_filterlog(self, dt_range, gid, host, stat, val): table_name = "filter" d_val = { "dts": dt_range[0], "dte": dt_range[1], "gid": gid, "host": host, "stat": stat, "val": val, } l_ss = [db_common.setstate(k, k) for k in d_val.keys()] sql = self.db.insert_sql(table_name, l_ss) self.db.execute(sql, d_val)