开发者

python sqlite3 update not updating

开发者 https://www.devze.com 2023-02-07 05:55 出处:网络
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))

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

精彩评论

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

关注公众号