简体   繁体   English

python sqlite3更新不更新

[英]python sqlite3 update not updating

Question: Why is this sqlite3 statement not updating the record? 问题:为什么这个sqlite3语句没有更新记录?


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. 我正在使用python和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. 但记录没有与腌制ret的新值一起更新。 it remains u''. 它仍然是你。 I can't figure out why. 我无法弄清楚为什么。 my where statement seems to work. 我的where声明似乎有效。 my 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. 在cur.execute之后,UPDATES和INSERTS需要COMMIT。

don't use 'AND', use a ','. 不要使用'AND',使用','。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM