Django - select_for_update() function / Locking Database Rows

preview_player
Показать описание
In this video, we'll look at the Django select_for_update() function, that can be used to lock the rows that are being returned from the database. This function can lock a single row (model) or multiple rows (QuerySet) from being updated outwith the current transaction.

This is useful for situations where you need to avoid concurrent transactions updating the data that has been retrieved, and we work through a small example in this video.

☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:

📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Intro
00:29 select_for_update() in Django
04:15 Installing PostgreSQL in Docker container
10:55 Locking rows with select_for_update()

▶️ Full Playlist:

𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:

📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:

#python #django #webdevelopment #database #sql
Рекомендации по теме
Комментарии
Автор

You are best teacher.. Love from India..

DhavalAhir
Автор

Thank you, you helped me in my interview. 🙌

mithileshgautam
Автор

I like this level of intensity! Thanks.

dmitrymikhailovnicepianomu
Автор

Super usefull. Thank you for your django and htmx videos!

alexdubkov
Автор

Thank you for another great video! I think this one might have ended up out of order in your playlist. Should this be the video after the atomic() function video, rather than the video before?

daviddehoog
Автор

Brother... try to upload more videos about django channels, signals, custom Middleware...

jackoffjames
Автор

hi, do you have solution for Like:
Multiple table field Sum calculation from parent model to get stock qty each product (stock qty= purchase_qty - purchase_return_qty - sales_qty + sales_qty )

sha-us
Автор

also does select update works with LIMIT? say I only want to select and lock 1 row

rakeshmali
Автор

but product on line 29 was never implemented or am i mad????

psymon
Автор

if there are concurrent 100 requests and they all try to select and update 10000 rows, then the first request locks all these 10000 rows while other 99 requests wait, right?

rakeshmali