当我想编译代码时,我得到这个错误,它本身所做的就是从mysql中的数据库中获取数据,然后将它们放在温度计图中,但是当要编译时,我得到了这个错误: >
“加载布局时出错”
这是te代码:
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__)
dataSQL = []
sql_conn = MySQLdb.connect('localhost', 'root', 'root', 'DB')
cursor = sql_conn.cursor()
cursor.execute("SELECT value FROM sensorParser where sensor='TC'")
#and timestamp >= timestamp()-4seg"
rows = cursor.fetchall()
for row in rows:
dataSQL.append(list(row))
labels = ['value']
df = pd.DataFrame.from_records(dataSQL, columns=labels)
app.layout = html.Div([
daq.Thermometer(
id='my-thermometer',
value=5,
min=0,
max=10,
style={
'margin-bottom': '5%'
}
),
dcc.Slider(
id='thermometer-slider',
value=5,
min=0,
max=10,
),
html.Div(daq.Thermometer(min=-5,max=105,value=df['value'],size=350,label='TEMPERATURA',
labelPosition='top',color='orange',showCurrentValue=True,units="°C"),className="six columns"),dcc.Interval(id='graph-update3',interval=1000, n_intervals=0),
])
@app.callback(
dash.dependencies.Output('my-thermometer', 'value'),
[dash.dependencies.Input('thermometer-slider', 'value')])
def update_thermometer(value):
return value
if __name__ == '__main__':
app.run_server(debug=True)
致谢。