def addperson(request): per = Person() per.p_name = '阿童木-' + str(random.randrange(10000000)) per.p_age = random.randrange(10, 100000) per.save() return HttpResponse('{}已满16岁!'.format(per.p_name))
def add_person(): person = Person() person.p_name = '我喜欢的人%d' % random.randrange(100) person.p_age = random.randrange(100) db.session.add(person) db.session.commit() return 'Add Sucess'
def add_persons(request): for i in range(10): p = Person() p.p_name = '啥子%d' % random.randrange(100) p.p_age = random.randrange(200) p.save() return HttpResponse('创建人员成功')
def person_add(request): # 添加人 person = Person() person.p_name = "呵呵哒%d" % random.randrange(1000) person.p_age = 180 # 存储 person.save() return HttpResponse("添加成功%d" % person.id)
def add_persons(request): for i in range(15): person = Person() flag = random.randrange(100) person.p_name = 'Tom%d' % i person.p_age = flag person.p_sex = flag % 2 person.save() return HttpResponse("创建成功!")
def add_persons(request): for i in range(15): person = Person() flag = random.randrange(1000) person.p_name = 'Tom {}'.format(flag) person.p_age = flag person.p_sex = True person.save() return HttpResponse('create successfully')
def add_persons(request): for i in range(15): person = Person() jia = random.randrange(100) person.p_name = "jia%d" % i person.p_age = jia person.p_sex = jia % 2 person.save() return HttpResponse("批量创建成功")
def add_persons(request): for i in range(15): person = Person() flag = random.randrange(100) person.p_name = "tom%d" % i person.p_age = flag person.p_sex = flag % 2 person.save() return HttpResponse('批量插入成功')
def add_persons(request): for i in range(10): person = Person() flag = random.randint(15, 45) person.p_name = 'Tom%d' % i person.p_age = flag person.p_sex = flag % 2 person.save() return HttpResponse('批量创建成功')
def add_persons(request): """一次性新增了多个数据库字段。""" for i in range(15): peo = Person() flag = random.randrange(1000000) peo.p_name = "tom-%d" % i peo.p_age = flag peo.p_sex = flag % 2 peo.save() return render(request, "add_PS.html")
def add_persons(request): for i in range(15): person = Person() flag = random.randrange(100) person.p_name = "Tom%d" % i person.p_age = flag person.p_sex = flag % 2 person.save() return HttpResponse("batch downloading!")
def add_persons(request): '''批量创建人''' for i in range(15): person = Person() flag = random.randrange(100) person.p_name = "Tom%d" % i person.p_age = flag person.p_sex = flag % 2 person.save() return HttpResponse("批量创建成功!")
def add_person(): p = Person() p.p_age = 15 p.p_name = "二狗" # 存到数据库 db.session.add(p) db.session.commit() return 'su'
def add_persons(): persons = [] for i in range(5): p = Person() p.p_name = 'haha%d' % random.randrange(100) p.p_age = random.randrange(100) persons.append(p) # 添加一组 # db.session 会话,和数据库链接的会话 db.session.add_all(persons) db.session.commit() print(persons) return '添加成功'
def addperson(request): per = Person() per.p_name = 'gui_' + str(random.randrange(50)) per.p_age = random.randrange(1,101) per.save() return HttpResponse('{}符合条件,加进去了'.format(per.p_name))