Data table column headers are numbers not the column names

I’ve got a table populating from a mysql db but the column headers are coming out as numbers 0,1,2,3, etc instead of the names they have. Any ideas on how to fix this anyone?

app = dash.Dash()
app.layout = html.Div([
    dcc.Interval(id= 'graph-update',interval=10*1000),

    Output('table', 'rows'),
    events=[Event('graph-update', 'interval')]
def gen_table():
    conn = pymysql.connect()
    query = ""
    c = conn.cursor()
    dh = pd.DataFrame([[ij for ij in i]for i in c])
    return dh.to_dict('records')

if __name__ == '__main__':

you should define them in the layout.

Oh sorry I forgot to add in the columns=[] bit but how do I get that fed from the callback?

do your columns change depending on the callback?

Yeah I’ve another graph and depending on the click Data from that the query changes and returns different columns

hmm… maybe you could have an empty div (container) and return the whole dt.Datatable in the callback?
Ive never done this but worth a shot.

yeah I’ve tried that but I’ll give it another shot and hope it was just a small mistake last time