Dashboard not getting updated

Hi Team,

Trying to run the below code but i am getting the old output and not the output for the code.

Kindly advice

import pandas as pd
import pyodbc
server='LAPTOP-OO3V36UA\SQLEXPRESS'
db='addy'

conn=pyodbc.connect('DRIVER={SQL Server}; SERVER=' +server + ';DATABASE=' + db + ';Trusted_connection=yes')

sql="""

SELECT * FROM Summry


"""

df=pd.read_sql(sql ,conn)
df
import dash
from dash.dependencies import Output, Input
import dash_core_components as dcc
import dash_html_components as html
from random import random
import plotly

app = dash.Dash(__name__)
app.layout = html.Div([
        dcc.Graph(id='live-update-graph-scatter', animate=True),
        dcc.Interval(
            id='interval-component',
            interval=1*1000
        )
    ])

@app.callback(Output('live-update-graph-scatter', 'figure'),
              [Input('interval-component', 'interval')])
def update_graph_scatter():
    
    trace1=go.Scatter(
    y=df['ACL'],
    x = df['DateandnTime'],
    mode='lines',
    name='ACL'
    
)
    layout = go.Layout(
    title='Daily Monitoring'
    )
    return {'data': trace1, 'layout': layout}
if __name__ == '__main__':
    app.run_server()

Hi @Adnan I think the problem is that you query the database only once at the beginning of the script, you need to fetch the new data inside the callback otherwise df is never updated. You can print df inside the callback to check whether it is updated, but I don’t think the problem is with Dash.

I added print df but it is showing an error
I even added the sql query after the call back it is giving an error could u please help what changes exactly needs to be done