我有一张桌子set_reminders
。我正在运行SELECT
查询以获取一行。即使将fetchone()
的值存储在变量中,然后像告诉我们in this question那样将其用于进一步使用后,它也会显示 TypeError 。下面是解决我的问题的代码。
@app.route('/',methods=['GET','POST'])
def index():
recur_next = ''
if request.method == 'POST' and request.form['btn']=='XYZ':
date = request.form['date']
subject = 'Event'
reminders='Placement Drive'
cur = mysql.connection.cursor()
search = cur.execute('SELECT DATE,SUBJECT,DESCRIPTION,RECUR_NEXT FROM set_reminder WHERE DATE=%s AND SUBJECT=%s AND DESCRIPTION=%s',(date,subject,reminders))
data = cur.fetchall()
a = cur.fetchone()
recur_next = a['RECUR_NEXT']
print(recur_next)
cur.close()
return '''<form method="post">
<input type="date" name="date">
<input type="submit" name="btn" value="XYZ">
</form>'''
File "def.py",line 22,in index
recur_next = a['RECUR_NEXT']
TypeError: 'NoneType' object is not subscriptable
这是显示的错误。请帮帮我。