def clear_database(): pg = Postgres() save_date = (dt.datetime.now() - dt.timedelta(days=3)).strftime("%Y-%m-%d %H:%M:%S") pg.execute(SqlText.sql_delete_real_phase.format(save_date)) pg.execute(SqlText.sql_delete_kde_vaue.format(save_date)) pg.db_close() print("数据库清理完成")
def parse_failed_detector_send(self, delta=15): current_time = dt.datetime.now() # current_date = current_time.date() start_time = (current_time - dt.timedelta(minutes=delta)).strftime('%H:%M:%S') end_time = (current_time).strftime('%H:%M:%S') current_date = str(current_time.date()) if IF_TEST: current_date = TEST_DATE failed_detector = self.parsing_failed_check(current_date, start_time, end_time) if failed_detector is not None: try: pg = Postgres(ConnectInf.pg_inf_inter_info) pg.execute(sql_delete_channel_data) node_inf = pg.call_pg_data(sql_get_node_inf, fram=True) node_inf.columns = ['node_id','FSTR_INTERSECTID'] merge_result = pd.merge(failed_detector,node_inf,how='left', on=['FSTR_INTERSECTID']) return_message = merge_result.values.tolist() pg.send_pg_data(sql=sql_send_parse_failed_detector, data=return_message) except Exception as e: print(e) return