Create an empty datatable

Hello everyone.
I’m new in the Bokeh World!
I was wondering if there was a way to create an empty datatable when the app is starting.
The idea is to populate data from a SQL database once the user specifies the datatable name and click on a button ‘download’, using Python callbacks.
Thanks for your help

Here is the code I have written so far but this doesn’t work.

tbl = DataTable (columns=[], source=ColumnDataSource({}))

def downloadUpdate(attr, old, new) :
    df = downloadAllDatasFromSQLDatabase (inp_server.value, slct_database.value, slct_datatable.value)
    tbl.columns=[TableColumn(field=Ci, title=Ci) for Ci in df.columns]
    tbl.source=ColumnDataSource({x:df[x].tolist() for x in df.columns})

btn_download = Button (label = "Download datas", width = 250)
btn_download.on_event('button_click', downloadUpdate)

I think you’d need to create a CDS with all the columns you will want, but with empty lists/arrays for the columns, rather than create a CDS with no columns at all.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.