备注信息收集 增加避免重复的校验
This commit is contained in:
parent
8010b6db4e
commit
3dc70a2756
|
|
@ -69,6 +69,12 @@ def submit_remarks():
|
||||||
# mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = "tikutest")
|
# mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = "tikutest")
|
||||||
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = "tiku")
|
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = "tiku")
|
||||||
mycursor = mydb.cursor()
|
mycursor = mydb.cursor()
|
||||||
|
sql = f"SELECT * FROM remarks WHERE ID = %s and remark_content = %s;"
|
||||||
|
val = (id,f"({category}){remarks}")
|
||||||
|
print(f"({category}){remarks}")
|
||||||
|
mycursor.execute(sql,val)
|
||||||
|
ret = mycursor.fetchall()
|
||||||
|
if len(ret) == 0:
|
||||||
sql = f"INSERT INTO remarks SET ID = %s, date = %s, remark_content = %s;"
|
sql = f"INSERT INTO remarks SET ID = %s, date = %s, remark_content = %s;"
|
||||||
val = (id,date,f"({category}){remarks}")
|
val = (id,date,f"({category}){remarks}")
|
||||||
mycursor.execute(sql,val)
|
mycursor.execute(sql,val)
|
||||||
|
|
@ -82,6 +88,9 @@ def submit_remarks():
|
||||||
mydb.commit()
|
mydb.commit()
|
||||||
mydb.close()
|
mydb.close()
|
||||||
return render_template('show_remarks.html', category=category, remarks=remarks)
|
return render_template('show_remarks.html', category=category, remarks=remarks)
|
||||||
|
else:
|
||||||
|
mydb.close()
|
||||||
|
return f"已有备注 ({category}){remarks}"
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
Reference in New Issue