Black Lives Matter. Please consider donating to Black Girls Code today.

Callback not working with pulldown input

Hi there,
relatively new to dash and trying to build a proper interface to our database to review information. I have a table that is populated with the results of an SQL call to our database. The peculiar behavior seems to be with:

@app.callback ([
    Output('metrics_table', 'columns'),
    Output('metrics_table', 'data')
    ], [Input('system_dropdown', 'value') ] )
def populateMetrics(input_value):
    columns=[{"name": i, "id": i} for i in df_metrics.columns]
    data= df_metrics.to_dict('records')
    return columns, data

pvq.getAvailableSystemMeasurements is a call to the database to return a dataframe of items.

If i just put an integer value into the call that produces df_metrics it works fine, table populates and all looks good. However if I let the input_value be used, it fails the query returning no values, which throws errors with the next two lines. Not sure why this isn’t working. Unfortunately using a breakpoint in my debugger does not seem to work within the callbacks so I can’t examine the variable input_value.

input_value is a string, you probably need to use int(input_value) in the function call.

1 Like

You can use print statements to print the value of the variable in the Terminal to debug.

1 Like