Python 如何在flask中显示mysql结果
大家晚上好, 我的名字是eric,我正在学习如何使用python在flask中构建,目前一切正常,并连接到数据库,我可以搜索没有问题,我有两个问题,我希望你能帮助我Python 如何在flask中显示mysql结果,python,html,flask,Python,Html,Flask,大家晚上好, 我的名字是eric,我正在学习如何使用python在flask中构建,目前一切正常,并连接到数据库,我可以搜索没有问题,我有两个问题,我希望你能帮助我 在我的查询中,它必须是100%正确的单词,我希望它与单词接近,以防大写或拼写错误 如何在屏幕上显示结果?目前,我只能得到“查找结果”或“无结果” 先谢谢你 @app.route("/", methods=['POST']) def Authenticate(): search = request.fo
@app.route("/", methods=['POST'])
def Authenticate():
search = request.form['si']
cursor = mysql.connect().cursor()
cursor.execute("SELECT * from Companys where B_Type='" + search + "'")
data = cursor.fetchone()
if data is None:
return "Could not find the data you are looking for"
else:
return "Found Data"
您可以使用
返回呈现模板('filename.html',data=data)
并且可以使用jinja2在HTML上呈现如下内容:
{{data}} 或跟随链接