python sqlite3更新不更新 [英] python sqlite3 update not updating

查看:48
本文介绍了python sqlite3更新不更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:为什么这个 sqlite3 语句没有更新记录?

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

信息:

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

我正在使用 python 和 sqlite3.这个语句不会抛出错误,它似乎被忽略了.出于测试原因,我将其包含在其下方:

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

返回一个记录就好了.但记录没有更新腌制 ret 的新值.它仍然是你''.我不明白为什么.我的 where 语句似乎有效.我的语法似乎是正确的,因为没有抛出错误.我不知道为什么它不起作用.

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. my syntax seems to be correct because there is no error being thrown. I'm clueless as to why exactly it doesn't work.

推荐答案

不要使用AND",使用,".

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

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

这篇关于python sqlite3更新不更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆