的Python 3 + Tkinter的和sqlite3的sqlite3.OperationalError ...我的sqlite语法有什么问题?
我在做一个模拟的应用程序保存在sqlite的
这里一段文本的功能:
def saveNote(self,note_id):
conn = db.connect(fname)
c = conn.cursor()
safeTitle=self.newNoteTitle.get()
safeContents=self.newNoteText.get("1.0",tk.END)
safeLink=self.newNoteLink.get()
safeRemarks=self.newNoteRemarks.get()
conn.execute('UPDATE notes SET (title,contents,remarks,link,created,last_modified,notebook_id) VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, ?) WHERE notes_id=5', (safeTitle, safeContents, safeRemarks, safeLink, 1))
conn.commit()
self.master.destroy()
当执行功能时,我得到这个错误:
conn.execute('UPDATE notes SET (title,contents,remarks,link,created,last_modified,notebook_id) VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, ?) WHERE notes_id=5', (safeTitle, safeContents, safeRemarks, safeLink, 1))
sqlite3.OperationalError: near "(": syntax error
我不明白为什么语法是错误的...(我是新来的Python)...谁能帮助我发现错误了吗?
谢谢
SQLite的语法图是非常有帮助的:例如,https://sqlite.org/lang_update.html和https://sqlite.org/lang_insert.html –
感谢您的链接,但我已经阅读并我的语法看起来好吗? –
您的语法有缺陷。 “VALUES”这个词不会出现在这个语法图的任何地方:https://sqlite.org/lang_update.html也不是'('或')'。 –