在我的sql语句中,我试图将2个值添加到记录中,其中此记录的id等于某个数字。所有这三个值都是变量。我收到错误" sqlite3.OperationalError:near" SET":语法错误"。
我做错了什么的任何线索? 谢谢!
self.db = sqlite3.connect("aLevelTracker.db")
self.cursor = self.db.cursor()
if self.typeOfAccount=="student":
self.cursor.execute("UPDATE student SET username = ? AND SET password = ? WHERE student_id = ?",((self.username),(self.passwordHash),(self.lastID)))
if self.typeOfAccount=="teacher":
self.cursor.execute("UPDATE teacher SET username=? AND SET password = ? WHERE teacher_id = ?",((self.username),(self.passwordHash),(self.lastID)))
self.db.commit()
self.db.close()
答案 0 :(得分:0)
您不需要AND
:
"UPDATE student SET username = ?, password = ? WHERE student_id = ?"
"UPDATE teacher SET username=?, password = ? WHERE teacher_id = ?"