anumaurya114exp commited on
Commit
c004bcb
·
1 Parent(s): 8d62920

added table output

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -153,7 +153,7 @@ def testSQL(sql):
153
  conn = dbEngine2.getConnection()
154
  df = pd.read_sql_query(sql, con=conn)
155
  dbEngine2.disconnect()
156
- table_output = gr.DataFrame(df)
157
  return disclaimerOutputStripping, table_output
158
  except Exception as e:
159
  errorMessage = {"function":"testSQL","error":str(e), "userInput":sql}
@@ -161,7 +161,7 @@ def testSQL(sql):
161
  dbEngine2.disconnect()
162
 
163
  print(f"Error occured during running the query {sql}.\n and the error is {str(e)}")
164
- table_output = gr.DataFrame(pd.DataFrame())
165
  return f"The query you entered throws some error. Here is the error.\n {str(e)}", table_output
166
 
167
 
@@ -261,7 +261,7 @@ with gr.Blocks() as demo:
261
  gr.Markdown("""<h1><center> Run Query </center></h1>""")
262
  text_input = gr.Textbox(label = 'Input SQL Query', placeholder="Write your SQL query here ...")
263
  text_output = gr.Textbox(label = 'Result')
264
- table_output = gr.DataFrame(pd.Dataframe())
265
  text_button = gr.Button("RUN QUERY")
266
  clear = gr.ClearButton([text_input, text_output])
267
  text_button.click(testSQL, inputs=text_input, outputs=[text_output, table_output])
 
153
  conn = dbEngine2.getConnection()
154
  df = pd.read_sql_query(sql, con=conn)
155
  dbEngine2.disconnect()
156
+ table_output = gr.Dataframe(df)
157
  return disclaimerOutputStripping, table_output
158
  except Exception as e:
159
  errorMessage = {"function":"testSQL","error":str(e), "userInput":sql}
 
161
  dbEngine2.disconnect()
162
 
163
  print(f"Error occured during running the query {sql}.\n and the error is {str(e)}")
164
+ table_output = gr.Dataframe(pd.DataFrame())
165
  return f"The query you entered throws some error. Here is the error.\n {str(e)}", table_output
166
 
167
 
 
261
  gr.Markdown("""<h1><center> Run Query </center></h1>""")
262
  text_input = gr.Textbox(label = 'Input SQL Query', placeholder="Write your SQL query here ...")
263
  text_output = gr.Textbox(label = 'Result')
264
+ table_output = gr.Dataframe(pd.DataFrame())
265
  text_button = gr.Button("RUN QUERY")
266
  clear = gr.ClearButton([text_input, text_output])
267
  text_button.click(testSQL, inputs=text_input, outputs=[text_output, table_output])