首页 > 其他 > 详细

ORM锁和事务

时间:2020-03-02 18:29:26      阅读:50      评论:0      收藏:0      [点我收藏+]

事务和锁

mysql:  中写法
select * from book where id=1 for update;

begin;  start transaction;
    select * from t1 where id=1 for update;
commit

rollback;


django orm中写法
models.Book.objects.select_for_update().filter(id=1)

事务

from django.db import transaction

@transaction.atomic
def index(request):
    
    ...


def index(request):
    ...
    with transaction.atomic():
        xxxx
    ...

ORM锁和事务

原文:https://www.cnblogs.com/saoqiang/p/12396970.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!