数据库可视化工具:
https://sqlitestudio.pl/index.rvt
from app01 import models def orm(request): #增加数据 # 方法1: # models.UserInfo.objects.create(username=‘root‘,password=‘root123‘) # 方法2: # obj = models.UserInfo(username=‘zte‘,password=‘zte‘) # obj.save() # 方法三: # dict1={‘username‘:‘zte1‘,"password":‘zte1‘ } # obj = models.UserInfo(**dict1) # obj.save() #查找数据 # result=models.UserInfo.objects.all() # # print result # for row in result: # print row.id,row.username,row.password # result = models.UserInfo.objects.filter(username=‘root‘) # result = models.UserInfo.objects.filter(username=‘root‘,password=‘root123‘) # for row in result: # print row.id,row.username,row.password #删除 # models.UserInfo.objects.filter(id=‘4‘).delete() #更新 models.UserInfo.objects.all().update(password=45678) return HttpResponse(‘adasd‘)
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models # Create your models here. class UserInfo(models.Model): username=models.CharField(max_length=32) password=models.CharField(max_length=64) class zte(models.Model): id=models.AutoField(primary_key=True) #主键,自增 username=models.CharField(max_length=32) password=models.CharField(max_length=64) email=models.CharField(max_length=64,null=True)
原文地址:https://www.cnblogs.com/qiangayz/p/8972673.html
时间: 2024-10-03 22:55:56