In Django, what does the select_for_update method do?
Correct answer
B. Locks selected rows in the database to prevent concurrent updates
16 views
B. Locks selected rows in the database to prevent concurrent updates
16 views
select_for_update() locks the selected rows until the transaction ends, so other transactions cannot change them in the meantime. It generates SELECT ... FOR UPDATE and must be used inside transaction.atomic().
It prevents race conditions in operations like balance updates.
Practise more Computer Science MCQs with answers and explanations on MCQsExam.com.
Not sure why the answer is B? Ask here and get an explanation.