From d65054e01533f62e63e1c8788da4b97309f65cee Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Thu, 4 May 2017 16:34:18 -0700 Subject: [PATCH] [sql lab] fix csv export where `%` in query (#2711) * [sql lab] fix csv export where in query * Prgoress --- superset/models/core.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/superset/models/core.py b/superset/models/core.py index 2a46e7dda086a..af76b26ce2261 100644 --- a/superset/models/core.py +++ b/superset/models/core.py @@ -575,16 +575,19 @@ def get_quoter(self): def get_df(self, sql, schema): sql = sql.strip().strip(';') eng = self.get_sqla_engine(schema=schema) - cur = eng.execute(sql, schema=schema) - cols = [col[0] for col in cur.cursor.description] - df = pd.DataFrame(cur.fetchall(), columns=cols) + + conn = eng.raw_connection() + cur = conn.cursor() + cur.execute(sql, **self.db_engine_spec.cursor_execute_kwargs) + + cols = [col[0] for col in cur.description] + df = pd.DataFrame(list(cur.fetchall()), columns=cols) def needs_conversion(df_series): if df_series.empty: return False - for df_type in [list, dict]: - if isinstance(df_series[0], df_type): - return True + if isinstance(df_series[0], (list, dict)): + return True return False for k, v in df.dtypes.iteritems():