SQLITE3 Python更新记录,变量不起作用?

时间:2018-02-11 19:23:54

标签: python mysql sql python-3.x sqlite

在我的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()

1 个答案:

答案 0 :(得分:0)

您不需要AND

"UPDATE student SET username = ?, password = ? WHERE student_id = ?"

"UPDATE teacher SET username=?, password = ? WHERE teacher_id = ?"