Hello!
I’m working on building a live-updating table (from a SQL db), and have had great success with the datatable option as so
app.layout = html.Div([
html.Div(
id='controls',
children=[
html.Button(
"Print",
id='las-print'
),
]
),
html.Div(
id='frontpage',
className='page',
# children=generate_frontpage()
),
html.Div(className='section', children=[
html.Div(
className='section-title',
children="LAS well"
),
html.Div(
className='page',
children=[
html.Div([dash_table.DataTable(id='pr-table',
# sort_action='native',
# filter_action='native',
# row_deletable=True,
style_cell={
'padding': '15px',
'width': 'auto',
'textAlign': 'center'
},
style_data={'whiteSpace': 'normal'},
css=[{'selector': '.dash-cell div.dash-cell-value',
'rule': 'display: inline; white-space: inherit; overflow: inherit; text-overflow: inherit;'}],
columns=[{"name": i, "id": i} for i in df.columns],
data=df.to_dict("rows")
),
dcc.Interval(id='interval_component',
interval=1000,
n_intervals=0
)
], className="row pretty_container table"),
html.Div(
id='pr-table-print'
)]
)
]),
])
@app.callback(Output('pr-table', 'data'), [Input('interval_component', 'n_intervals')])
def update_table(n_intervals):
con = sqlite3.connect('database.db')
df = pd.read_sql_query("SELECT title, link, ticker, release_date FROM globenewswire", con)
data = df.to_dict('records')
return data
What I would like however, is the interval update functionality for a standard HTML table as in
[html.Tr([html.Th(col) for col in df.columns])] +, id='table', style=dict(margin="auto")),
Have tried searching up and down for a way to do it, so not sure if it’s even possible.
Any help would be much appreciated!