code2code

导航

数据库增删改查使用

//增加

test1 = Test(name='runoob')

//查找 select * 

Test.objects.all()

// select * from where id = 1

response2 = Test.objects.filter(id=1)

//查找并排序

Test.objects.order_by("id")

 

//更新

test1 = Test.objects.get(id=1)

test1.name = 'Google'

test1.save()

//删除

test1 = Test.objects.get(id=1)

test1.delete()

posted on 2020-09-22 14:24  yz6zy  阅读(95)  评论(0编辑  收藏  举报