This is my Python code -
这是我的Python代码 -
cursor.execute("""UPDATE tasks SET task_owner=%s,task_remaining_hours=%s, task_impediments=%s,task_notes=%s WHERE task_id=%s""", (new_task_owner,new_task_remaining_hours,new_task_impediments,
new_task_notes,task_id))
This is the SQL statement I try in SQLite3 manager (Firefox extension)
这是我在SQLite3管理器中尝试的SQL语句(Firefox扩展)
UPDATE tasks SET task_owner=%s,task_remaining_hours=%d,task_impediments=%s,task_notes=%s WHERE task_id=%d,("sumod",10,"none","test",1)
The error I get is -
我得到的错误是 -
sqlite3.OperationalError: near "%": syntax error
I have tried many web searches including SO, tutorials and self-troubleshooting, but this error does not go away. What exactly I am doing wrong here.
我尝试了很多网络搜索,包括SO,教程和自我排除故障,但这个错误并没有消失。究竟我在这里做错了什么。
1 个解决方案
#1
29
I believe Python's SQLite implementation uses ?
placeholders, unlike MySQLdb's %s
. Review the documentation.
我相信Python的SQLite实现使用?占位符,与MySQLdb的%s不同。查看文档。
cursor.execute("""UPDATE tasks SET task_owner = ? ,task_remaining_hours = ?,task_impediments = ?,task_notes = ? WHERE task_id= ? """,
(new_task_owner,new_task_remaining_hours,new_task_impediments,new_task_notes,task_id))
#1
29
I believe Python's SQLite implementation uses ?
placeholders, unlike MySQLdb's %s
. Review the documentation.
我相信Python的SQLite实现使用?占位符,与MySQLdb的%s不同。查看文档。
cursor.execute("""UPDATE tasks SET task_owner = ? ,task_remaining_hours = ?,task_impediments = ?,task_notes = ? WHERE task_id= ? """,
(new_task_owner,new_task_remaining_hours,new_task_impediments,new_task_notes,task_id))