我有一个包含一些数据的SQLite数据库。现在,我想用Python更新此数据。
这是我使用的Python代码:
print("Place your tag to activate it...")
forename = input("Forename: ")
surename = input("Surename: ")
permission= input("Permission: ")
_id = Rfid.readRfid()
cursor.execute("UPDATE rfidTage SET (forename = ?, surename = ?, permission = ? WHERE id = ?)", (str(forename), str(surename), str(permission), long(_id)))
方法Rfid.readRfid()
仅读取Rfid标记,并将ID返回为long
。
我试图运行代码并收到以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "DatabaseWriter.py", line 27, in updateTag
cursor.execute('''UPDATE rfidTage SET (forename = ?, surename = ?, permission = ? WHERE id = ?)''', (str(forename), str(surename), str(permission), long(_id)))
sqlite3.OperationalError: near "=": syntax error
我将不胜感激。
答案 0 :(得分:2)
您不应该在SET
运算符之后使用括号。
您可以在以下资源上获得更多详细信息:
您的查询应为UPDATE rfidTage SET forename = ?, surename = ?, permission = ? WHERE id = ?
。