Parcourir la source

查表时去除table_type条件

liweiquan il y a 2 ans
Parent
commit
9f59cf4e30
2 fichiers modifiés avec 5 ajouts et 4 suppressions
  1. 2 1
      app/core/datasource/mysql.py
  2. 3 3
      app/crud/job_jdbc_datasource.py

+ 2 - 1
app/core/datasource/mysql.py

@@ -96,7 +96,8 @@ class MysqlDS(DataSourceBase):
 
 
     def list_tables(self):
-        sql = f'SELECT table_name FROM information_schema.tables WHERE table_type = "base table" AND table_schema="{self.database_name}"'
+        # table_type = "base table" AND
+        sql = f'SELECT table_name FROM information_schema.tables WHERE table_schema="{self.database_name}"'
         res = self._execute_sql([sql])
         return flat_map(lambda x: x, res[0])
 

+ 3 - 3
app/crud/job_jdbc_datasource.py

@@ -8,14 +8,14 @@ from app.utils import decode_user
 
 
 def _decode(url, datasource, database_name):
-    return url.replace('jdbc:', '').replace('hive2://', '').replace(f'{datasource}://', '').replace(f'/{database_name}',
-                                                                                                    '')
+    url =  url.replace('jdbc:', '').replace('hive2://', '').replace(f'{datasource}://', '').replace(f'/{database_name}','')
+    return url.split('?')[0]
+
 
 
 def _format_datasource(db: Session, item: schemas.JobJdbcDatasourceBase, ds_id: int = 0):
     if ds_id != 0:
         item = db.query(models.JobJdbcDatasource).filter(models.JobJdbcDatasource.id == ds_id).first()
-        print('===',item.__dict__)
         if not item:
             raise Exception('未找到该数据源')
         item.jdbc_url = _decode(item.jdbc_url, item.datasource, item.database_name)