我有一个简单的TRANSFORM Count(Table1.[Division]) AS CountOfDivision
SELECT Table1.[Branch], Table1.Division
FROM Table1
GROUP BY Table1.[Branch], Table1.Division
PIVOT Table1.[RequestType];
应用程序,它使用一组参数查询数据库,然后绘制结果。这工作正常,但是如何重新启动进程(查询数据库,绘制数据),只要它仍在运行并刷新页面或者再次单击“提交”按钮?
Flask
view.html
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def index():
form = InputForm(request.form)
if request.method == 'POST' and form.validate():
data = queryDatabase(form.startdate.data, form.enddate.data)
result = plotData(data)
else:
result = None
return render_template('view.html', form=form, result=result)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)
答案 0 :(得分:1)
您应该使用队列,例如其他人提到的Celery + Redis或Celery + RabbitMq。您可以在此处举例:http://eon01.com/blog/celery-worker-rabbitmq-broker-step-by-step-introduction/