Here is a snippet of my code and the last few lines of the output dialogue. I am using Example 1 from Part 5. Sharing Data Between Callbacks | Dash for Python Documentation | Plotly.
When I run the code below, I get that error message, but then it finally ends up working and creating the data table after about 1-2 minutes.
Now If I remove the params = [value] part of my sql query and just hard key in the company_code instead of passing it in as a parameter via a drop down , I still get that same error message below, but it eventually ends up working and creating the data table in less than 10 seconds instead of 1-2 minutes.
Any ideas why passing the parameter in would make it take so much longer to run?
@app.callback(
Output('intermediate-value', 'children'),
[Input('submit-button', 'n_clicks')],
[State('drop-down, 'value')])
def clean_data(n_clicks, value):
if n_clicks:
df = pd.read_sql_query("""SELECT data FROM sql_view
WHERE x is NOT NULL and company_code = ?
and date between '2/1/20' and '2/15/20' """, cnxn, params = [value])
return df.to_json(date_format='iso', orient='split')
@app.callback(Output('table1', 'children'), [Input('intermediate-value', 'children')])
def update_graph(jsonified_cleaned_data):
dff = pd.read_json(jsonified_cleaned_data, orient='split')
data = dff.to_dict('rows')
columns = [{"name": i, "id": i,} for i in (dff.columns)]
return dt.DataTable(data=data, columns=columns)
>>>output:
File "C:\Users\me\Anaconda3\lib\site-packages\pandas\io\common.py", line 232, in get_filepath_or_buffer
raise ValueError(msg.format(_type=type(filepath_or_buffer)))
ValueError: Invalid file path or buffer object type: <class 'NoneType'>
127.0.0.1 - - [11/Jun/2020 18:51:17] "POST /_dash-update-component HTTP/1.1" 500 -