获取特定用户返回的值 'none'
Fetching the value of particular user returning 'none'
- 我正在使用 postgres 数据库。我正在尝试获取
designation
列的值,但它是 returning none
.
- 用户正在输入电子邮件 ID 和密码,然后搜索特定用户的特定列,这将 return 'designation' 列的值。
application.py
email_entered = request.form['email']
password_entered = request.form['password']
# check the role of the user
sql_role_query = """SELECT users.designation FROM users WHERE users.email = %s"""
role = cursor.execute(sql_role_query, record_to_search)
print("Executed role query")
print(role)
if(role == 'Admin'):
return redirect(url_for('listuser'))
else:
return redirect(url_for('createuser'))
connection.commit()
- 当做
print(role)
时 returning none
您必须在调用 execute
后获取结果。
尝试下一步:
cursor.execute(sql_role_query, record_to_search)
role = cursor.fetchone()
- 我正在使用 postgres 数据库。我正在尝试获取
designation
列的值,但它是 returningnone
. - 用户正在输入电子邮件 ID 和密码,然后搜索特定用户的特定列,这将 return 'designation' 列的值。
application.py
email_entered = request.form['email']
password_entered = request.form['password']
# check the role of the user
sql_role_query = """SELECT users.designation FROM users WHERE users.email = %s"""
role = cursor.execute(sql_role_query, record_to_search)
print("Executed role query")
print(role)
if(role == 'Admin'):
return redirect(url_for('listuser'))
else:
return redirect(url_for('createuser'))
connection.commit()
- 当做
print(role)
时 returningnone
您必须在调用 execute
后获取结果。
尝试下一步:
cursor.execute(sql_role_query, record_to_search)
role = cursor.fetchone()