示例#1
0
def test(loop):
    yield from orm.create_pool(loop=loop,
                               user='******',
                               password='******',
                               db='awesome')
    u = User(name='Test',
             email='*****@*****.**',
             passwd='1234567890',
             image='about:blank')
    yield from u.save()
    yield from orm.destory_pool()
示例#2
0
def test(loop):
    yield from orm.create_pool(loop=loop,
                               user='******',
                               password='******',
                               db='etcyouhui',
                               charset='utf8')
    u = User(name='Test',
             email='*****@*****.**',
             password='******',
             image='about:blank')
    yield from u.save()
    yield from orm.destory_pool()
示例#3
0
def test(loop):
    yield from orm.create_pool(loop,
                               user='******',
                               password='******',
                               db='awesome')

    u = User(name='Test2',
             email='*****@*****.**',
             passwd='1234567890',
             image='about:lank')

    yield from u.save()
    yield from orm.destory_pool()
示例#4
0
def test():
    yield from orm.create_pool(loop=loop,
                               user='******',
                               password='******',
                               database='awesome')
    u = User(name='Test_1',
             email='*****@*****.**',
             passwd='1234567890',
             image='about:blank')
    yield from u.save()
    # r = User.findAll()
    # for x in r:
    # 	print('******:%s' %x.email)
    yield from orm.destory_pool()
示例#5
0
def test(loop=None):
    try:
        yield from create_pool(loop, host='127.0.0.1', port=3306, user='******', password='******', db='test')
    except BaseException as e:
        print('create pool failed!')

    roleCol = [{'name':'Dolores','id':'1'},
               {'name':'Ford','id':'2'},
               {'name':'Maeve','id':'3'},
               {'name':'Bernard','id':'4'},
               {'name':'William','id':'5'}
              ]
    for k in range(len(roleCol)):
        v = roleCol[k]
        user = models.User(id=models.get_guid(), name=v['name'], \
                           email=v['name']+'@westworld.com',passwd=v['id'])
        yield from user.save()
    user = models.User()
    print(user.findAll())
    try:
        yield from destory_pool()
    except BaseException as e:
        print('destory pool failed!')
示例#6
0
def test(loop):
    yield from orm.create_pool(loop=loop, host='localhost', port=3307, user='******', password='******', db='awesome')
    u = User(name='testaaa733ss447',email='*****@*****.**',passwd='test',image='about:blank')
    # yield from u.save()
    print(u)

    # 测试findAll
    users = yield from User.findAll(orderBy='created_at')
    for user in users:
        print(user)

    # 测试update语句
    user = users[1]
    user.email = '*****@*****.**'
    user.name = 'guest'
    yield from user.update()
    # 测试count rows语句
    # rows = yield from User.findAll(orderBy='created_at')
    # logging.info('rows is %s' % rows)
    #
    # # 测试insert into语句
    # if rows < 3:
    #     for idx in range(5):
    #         u = User(
    #             name='test%s' % idx,
    #             email='*****@*****.**' % idx,
    #             passwd='orm123%s' % idx,
    #             image='about:blank'
    #         )
    #         row = yield from User.countRows(where='email = ?', args=[u.email])
    #         if row == 0:
    #             yield from u.save()
    #         else:
    #             print('the email is already registered...')

    yield from orm.destory_pool()
示例#7
0
文件: orm_test.py 项目: LRG00/Weppy
def test():
    yield from orm.create_pool(loop, user='******', password='******', db='weppy')
    user = User(name="admin", password='******', is_admin=True)
    yield from user.save()
    yield from orm.destory_pool()
示例#8
0
def  test(loop):
    yield from orm.create_pool(loop=loop, host='localhost', port=3306, user='******', password='******', db='awesome')
    u = User(name='Test', email='*****@*****.**', passwd='123456', image='about:blank',id='123')
    yield from u.save()
    yield from orm.destory_pool()