Could you help me? I am new with Holoviews, I have this code in python and I don’t know how to make the graph consult the database every 20 seconds in search of new data to graph
# Importar librerías
import polars as pl
from dash import html,Dash
import holoviews as hv
from holoviews.plotting.plotly.dash import to_dash
from sqlalchemy import create_engine
def curva():
ER = "T00199"
REGISTROS = 'T00199FT0E01 T00199FT0S02 T00199LT0001 T00199ZVI001 T00199ZVI002'
REGISTROS = REGISTROS.split(' ')
conn = create_engine(f"sqlite:///HIST/{ER}.db").connect()
df = []
curvas = []
i = 0
for REGISTRO in REGISTROS:
query = f"SELECT tiempo,valor FROM {REGISTRO}"
df.append(pl.read_database(query=query,connection=conn).with_columns(pl.col('tiempo').str.strptime(pl.Datetime,'%Y-%m-%d %H:%M:%S%.3f',strict=False).cast(pl.Datetime)))
curvas.append(hv.Curve((df[i]['tiempo'], df[i]['valor']), 'Tiempo', 'Valor', label=f'{REGISTRO}').opts(show_legend=True,xaxis="bottom",xlabel="Tiempo",title=f"Estación {ER}",show_title=True))
if i == 0:
curve = curvas[i]
elif i > 0:
curve = curve * curvas[i]
i = i+1
conn.close()
return [curve]
app = Dash(__name__)
components = to_dash(app,hvobjs=curva(), reset_button=False)
app.layout = html.Div(components.children)
if __name__ == "__main__":
app.run(debug=True)