Python sqlite3 update without update

Question: Why does this sqlite3 statement not update the record?


information:

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

I am using python and sqlite3. this operator does not throw an error; it seems that it is incorrectly ignored. for testing reasons, I have included it below:

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

Which returns a record is just fine. but the record does not match the date of the new pickled ret value. he stays u. '' I can’t understand why. my expression seems to work. my syntax seems correct because the error does not occur. I don’t know why this is not working.

+4
source share
2 answers

do not use 'AND', use ','.

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

If the problem persists after you correct your syntax. Make sure you use:

 conn.commit() 

After cur.execute, UPDATES and INSERTS require COMMIT.

+12
source

Source: https://habr.com/ru/post/1337632/


All Articles