From 7a0c88b3b5deb9b01d5b3cacc1720b627c2f5ea6 Mon Sep 17 00:00:00 2001 From: Teingi <jingshun.tq@antgroup.com> Date: Tue, 10 Dec 2024 16:07:04 +0800 Subject: [PATCH] Simplify the display of table information in the tabledump result. --- handler/gather/gather_tabledump.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/handler/gather/gather_tabledump.py b/handler/gather/gather_tabledump.py index 862b904f..bffd9b80 100644 --- a/handler/gather/gather_tabledump.py +++ b/handler/gather/gather_tabledump.py @@ -126,7 +126,8 @@ def __get_table_schema(self): columns, result = self.tenant_connector.execute_sql_return_columns_and_data(sql) if result is None or len(result) == 0: self.stdio.verbose("excute sql: {0}, result is None".format(sql)) - self.__report(sql, columns, result) + else: + self.__report_simple(sql, result[0][1]) return True except Exception as e: self.stdio.error("show create table error {0}".format(e)) @@ -235,6 +236,14 @@ def __report(self, sql, column_names, data): except Exception as e: self.stdio.error("report sql result to file: {0} failed, error:{1} ".format(self.file_name, e)) + def __report_simple(self, sql, data): + try: + with open(self.file_name, 'a', encoding='utf-8') as f: + f.write('\n\n' + 'obclient > ' + sql + '\n') + f.write(data) + except Exception as e: + self.stdio.error("report sql result to file: {0} failed, error:{1} ".format(self.file_name, e)) + def __extract_string(self, s): if '@' in s: at_index = s.index('@')