Skip to content

Commit

Permalink
[sql lab] fix csv export where % in query (#2711)
Browse files Browse the repository at this point in the history
* [sql lab] fix csv export where  in query

* Prgoress
  • Loading branch information
mistercrunch authored May 4, 2017
1 parent 5d5060e commit d65054e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions superset/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit d65054e

Please sign in to comment.