查询未通过flask_mysql运行

时间:2019-06-19 03:25:20

标签: python mysql python-3.x flask mysql-python

尽管存储在变量中,但没有将值传递给选择查询,我却无法从选择查询中检索数据

from flaskext.mysql import MySQL

@app.route("/loginscr/",methods =['POST'])
def loginscr():

    username = request.form['username']
    password = request.form['password']

    print(request.form.to_dict())
    cursor = connection.cursor()
    cursor.execute('Select * from basics where username = %s AND password = %s',(username,password))
    account = cursor.fetchone()
    if account is not None:
        print("Successfull")
    else:
        print("UnSuccessfull")
    return "true"

1 个答案:

答案 0 :(得分:0)

fetchone()不返回整数。替换

if(account == 1):

使用

if account is not None:

或者,更像Python一样,

if account: