开发者

python sqlite3 update not updating

Question: Why is this sqlite3 statement not updating the record?


Info:

cur.execute('UPDATE workunits SET Completed=1 AND Returns=(?) WHERE PID=(?) AND Args=(?)',(pickle.dumps(Ret),PID,Args))

I'm using python and sqlite3. this statement does not throw an error, it just seems like it is out right ignored. for testing reasons I included below it:

cur.execute('SELECT * FROM workunits WHERE PID=(?) AND Args=(?)',(PID,Args))

Which returns a record just fine. but the record doesn't up date with the new value of the pickled ret. it remains u''. I can't figure out why. my where statement seems to work. m开发者_如何学Cy syntax seems to be correct because there is no error being thrown. I'm clueless as to why exactly it doesn't work.


If the problem persists after you fixed your syntax. Please make sure you're using:

conn.commit()

After cur.execute, UPDATES and INSERTS require COMMIT.


don't use 'AND', use a ','.

cur.execute('UPDATE workunits SET Completed=1, Returns=? WHERE PID=? AND Args=?',
    (pickle.dumps(Ret), PID, Args)
)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜