From 80f88465fa3b669b29151d2040a8afc17152e311 Mon Sep 17 00:00:00 2001 From: rugod <43984892+chenyu1st@users.noreply.github.com> Date: Sun, 16 Oct 2022 11:41:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E9=BB=98=E8=AE=A4postgres?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E5=BA=93=E8=A2=AB=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E7=9A=84=E9=80=BB=E8=BE=91=20(#1905)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 更改默认postgres的数据库被过滤的逻辑 Co-authored-by: hhyo (cherry picked from commit a094a7c44b1c530c08dcd026ea96692a997e8ec1) --- sql/engines/pgsql.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sql/engines/pgsql.py b/sql/engines/pgsql.py index 0146469743..c7b5f72e24 100644 --- a/sql/engines/pgsql.py +++ b/sql/engines/pgsql.py @@ -1,5 +1,5 @@ # -*- coding: UTF-8 -*- -""" +""" @author: hhyo、yyukai @license: Apache Licence @file: pgsql.py @@ -55,9 +55,7 @@ def get_all_databases(self): """ result = self.query(sql=f"SELECT datname FROM pg_database;") db_list = [ - row[0] - for row in result.rows - if row[0] not in ["postgres", "template0", "template1"] + row[0] for row in result.rows if row[0] not in ["template0", "template1"] ] result.rows = db_list return result @@ -93,8 +91,8 @@ def get_all_tables(self, db_name, **kwargs): :return: """ schema_name = kwargs.get("schema_name") - sql = f"""SELECT table_name - FROM information_schema.tables + sql = f"""SELECT table_name + FROM information_schema.tables where table_schema ='{schema_name}';""" result = self.query(db_name=db_name, sql=sql) tb_list = [row[0] for row in result.rows if row[0] not in ["test"]] @@ -111,7 +109,7 @@ def get_all_columns_by_tb(self, db_name, tb_name, **kwargs): """ schema_name = kwargs.get("schema_name") sql = f"""SELECT column_name - FROM information_schema.columns + FROM information_schema.columns where table_name='{tb_name}' and table_schema ='{schema_name}';""" result = self.query(db_name=db_name, sql=sql)