【发布时间】:2021-11-16 14:07:11
【问题描述】:
我有以下问题: 我正在(同时)对来自同一个数据库的 sql 请求进行处理,第二个请求取决于第一个请求的结果: 例如
def get_alldata(timestart):
statement = f""" SELECT * FROM "xxx"."xxx" WHERE timestart>=toDateTime('{timestart}')"""
df = client.query_dataframe(statement) #note that i already defined my
#client from clickhouse and it works
return df
#now the second
def second_request(id, time, line): #note that i get the id,time and line from the table(df) of
#the first function (i'm working
#with dash plotly) so i saved df in a Store and used it for
#the second function
statement = f'''SELECT student,class FROM "xxx"."xxx" WHERE id IN ({id}) AND time IN ({time}) AND line IN ({line})'''
df = client.query_dataframe(statement)
return df
第一个功能在我的应用程序中有效,但当涉及到第二个时,我收到此错误:
套接字关闭时出错:[WinError 10038] 与不是套接字的对象相关的操作
还有 AttributeError: 'NoneType' object has no attribute 'close'
我尝试在网上查找有关套接字的信息,但没有找到与我的问题相关的内容
有人有想法吗??
我在破折号的两个回调中调用函数
@app.callback(Output('id', 'options'),
Output('time', 'options'),
Output('line', 'options'),
[Input('loaded_data', 'data'),
]
)
def get_first_fuction(data):
df = get_alldata(data) # then i used it for a dropdown for the three outputs
.
.
@app.callback(
Output('graph', 'children'),
[Input('id', 'value'),
Input('time', 'value'),
Input('line', 'value'),
]
)
def second_function(id,time,line):
df = second_request(id,time,line)
# and i use it for a plot
# I get the error by this df
【问题讨论】:
标签: python sql sockets plotly-dash clickhouse