Answer the question
In order to leave comments, you need to log in
How to update all entries by list id?
There is a database with columns ID(int), Status(int)
How, having a list of IDs (of N pieces), make a request to update data for all records from this list of IDs?
(You need to change the value of the Status field)
How will the request look like? Do not send N requests for each id separately...
Answer the question
In order to leave comments, you need to log in
If performance is not critical (the id list is not very large), then you can simply use executemany (it actually runs separate updates, but automatically according to the list).
cur.executemany('update mytab set status = 1 where id = ?', ((id, ) for id in idlist) )
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question