Пример #1
0
def add_person():
    p = Person()
    p.p_name = "Sam %d" % random.randrange(100)

    db.session.add(p)
    db.session.commit()
    return 'Person add Success'
Пример #2
0
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'
Пример #3
0
def add_person(request):
    # person = Person.objects.create(p_name="Sunck", p_age=15, p_sex=True)

    # 是"" ,不是 None Null, 不能重写 __init__ ,可以通过其他手段,实现属性自定义赋值
    person = Person(p_age=28)

    person = Person.create('Jack')
    person.save()
    return HttpResponse("Jack 创建成功")
Пример #4
0
def add_person(request):

    username = request.GET.get("username")

    person = Person()
    person.p_name = username
    person.save()

    return HttpResponse("Person%d created success!" % person.id)
Пример #5
0
def add_person():
    p = Person()

    p.p_age = 15
    p.p_name = "二狗"

    # 存到数据库
    db.session.add(p)
    db.session.commit()
    return 'su'
Пример #6
0
def add_person():
    p = Person()
    p.p_name = '洪泽飞%d' % (random.randrange(100))

    # 将数据添加到本次数据库的链接会话中
    db.session.add(p)
    # 提交会话
    db.session.commit()

    return 'Person Create Success '
Пример #7
0
def add_person():
    """添加成员"""
    p = Person()

    p.p_name = "小朋友%d号" % random.randrange(100)

    db.session.add(p)

    db.session.commit()

    return 'Person Add Success'
Пример #8
0
def add_person(request):
    # person = Person.objects.create(p_name='sunck', p_age=16, p_sex=True)
    # person = Person(p_name='hjl', p_age=18, p_sex=True, p_hobby='sleeping')

    person = Person.create(p_name='jack')
    person.save()

    return HttpResponse('加入一个用户成功')
Пример #9
0
def add_person(request):
    # person = Person.objects.create(p_name='WangGang', p_age=20, p_sex=False)
    # person = Person(p_age=28)
    person = Person.create('Jack')

    person.save()

    return HttpResponse('创建成功!')
Пример #10
0
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 '添加成功'
Пример #11
0
def add_person(request):

    # person = Person.objects.create(p_name='mm',p_age=13,p_sex=True)

    person = Person.create('Jack')

    person.save()

    return HttpResponse("sunck")
Пример #12
0
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')
Пример #13
0
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('批量插入成功')
Пример #14
0
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("创建成功!")
Пример #15
0
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('批量创建成功')
Пример #16
0
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("批量创建成功")
Пример #17
0
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")
Пример #18
0
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!")
Пример #19
0
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("批量创建成功!")
Пример #20
0
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))
Пример #21
0
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('创建人员成功')
Пример #22
0
def person_add(request):
    # 添加人
    person = Person()
    person.p_name = "呵呵哒%d" % random.randrange(1000)
    person.p_age = 180
    # 存储
    person.save()
    return HttpResponse("添加成功%d" % person.id)
Пример #23
0
def add_person(request):
    """
    ##一次性新增一个数据库字段的三种方式:
    1.先实例化对象,然后依次或者随意给类属性赋值(没有赋值的属性,默认保存为blank),最后执行对象的save方法;
    2.直接用类的方法,但create方法内部需要填写所有字段; Person.objects.create()
    3.将类实例化的过程中,直接在类中赋值属性(赋值所有属性),然后用实例化对象的save方法:peo = Person()   peo.save()
    4.在模型中(models.py中Person模型)创造了一个自定义的create类方法,然后用实例化后的对象执行save方法:Person.create()  peo.save()
    """

    flag = random.randrange(10000)
    # 方法一:
    # peo = Person()
    # peo.p_age = flag
    # peo.save()
    # 方法二:
    # #Person.objects.create(p_name="bob %d" % flag, p_age=15, p_sex=1)
    # 方法三:
    # ##peo = Person(p_name="Bob %d" % flag, p_age=15, p_sex=1)
    # ##peo.save()
    # 方法四:
    peo = Person.create(p_name="wurui")
    peo.save()
    return HttpResponse("add one")
Пример #24
0
def add_person(request):
    person = Person()
    person.p_name = '小明%d' % random.randrange(1000)

    person.save()
    return HttpResponse('用户创建成功%d' % person.id)
Пример #25
0
def add_person():
    p = Person()
    p.name = "姬野%s" % random.randrange(1000)
    p.save()

    return "add person success"
Пример #26
0
def add_person(request):
    # person = Person.objects.create(p_name='sunck', p_age=15, p_sex=True)
    # person = Person(p_age=28)
    person = Person.create('Jack')
    person.save()
    return HttpResponse('Sunck succeed')
Пример #27
0
def crate_person():
    person = Person()
    person.person_name = 'mark%d' % random.randrange(100)
    db.session.add(person)  # 插入数据的操作
    db.session.commit()  # 一定记得要提交
    return '人员创建成功'
Пример #28
0
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))
Пример #29
0
def add_person(request):
    # person = Person.objects.create(p_name="jack", p_age=30, p_sex=False)
    # person = Person(p_name='Rose',  p_age=20, p_sex=False)
    person = Person.create('Sharon')
    person.save()
    return HttpResponse("Jack create success")
Пример #30
0
def add_person():
    p = Person()
    p.p_name = '谁着了拉出去枪毙%d' % random.randrange(100)
    db.session.add(p)
    db.session.commit()
    return 'Person Add Success'