2012-03-24 14 views
12

Das ist mein Python-Code -Sqlite3 - Update Tabelle Python Code - Syntaxfehler in der Nähe% s

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)) 

Dies ist die SQL-Anweisung I in SQLite3 Manager versuchen (Firefox-Erweiterung)

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) 

der Fehler, den ich bekommen ist -

sqlite3.OperationalError: near "%": syntax error 

ich habe mit vielen Web-Suche versucht, SO, Tutorials und Selbstfehlersuche, aber das Fehler geht nicht weg. Was genau mache ich hier falsch?

Antwort

24

Ich glaube, Python SQLite Implementierung verwendet ? Platzhalter, im Gegensatz zu MySQLdb %s. Review the documentation.

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)) 
+0

Vielen Dank! Das hat wirklich gut funktioniert. – Sumod

Verwandte Themen