|
@@ -82,13 +82,15 @@ class MysqlDS(DataSourceBase):
|
|
|
|
|
|
|
|
|
def get_preview_data(self, table_name, limit=100):
|
|
|
- sql1 = f'SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA="{self.database_name}" AND TABLE_NAME="{table_name}"'
|
|
|
+ # sql1 = f'SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA="{self.database_name}" AND TABLE_NAME="{table_name}"'
|
|
|
+ table_schema = self.get_table_schema(table_name)
|
|
|
sql2 = f"SELECT * FROM {table_name} LIMIT {limit}"
|
|
|
- res = self._execute_sql([sql1, sql2])
|
|
|
+ res = self._execute_sql([sql2])
|
|
|
logger.info(res)
|
|
|
return {
|
|
|
- 'header': flat_map(lambda x: x, res[0]),
|
|
|
- 'content': res[1]
|
|
|
+ # 'header': flat_map(lambda x: x, res[0]),
|
|
|
+ 'header': [str(column).split(':')[1] for column in table_schema],
|
|
|
+ 'content': res[0]
|
|
|
}
|
|
|
# db_connection = create_engine(self.connection_str)
|
|
|
# df = pd.read_sql(sql, con=db_connection)
|