lhoestq HF staff commited on
Commit
5b87dc7
1 Parent(s): 5503ee2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -1
app.py CHANGED
@@ -7,7 +7,7 @@ def greet(SQL_Query):
7
  if "limit" not in SQL_Query.lower():
8
  raise gr.Error("You should use the LIMIT clause or it may take too much time to run your query. For example: ```LIMIT 10000```")
9
  df = con.sql(SQL_Query).df()
10
- if df.columns: # truncate long strings
11
  df = df.apply(lambda x: x.apply(lambda y: y[:150 // len(df.columns)] + "..." if isinstance(y, str) and len(y) > 150 // len(df.columns) else y))
12
  return df
13
 
 
7
  if "limit" not in SQL_Query.lower():
8
  raise gr.Error("You should use the LIMIT clause or it may take too much time to run your query. For example: ```LIMIT 10000```")
9
  df = con.sql(SQL_Query).df()
10
+ if len(df.columns) > 0: # truncate long strings
11
  df = df.apply(lambda x: x.apply(lambda y: y[:150 // len(df.columns)] + "..." if isinstance(y, str) and len(y) > 150 // len(df.columns) else y))
12
  return df
13