コード例 #1
0
 async def test_create(self):
     e1 = model.LitemallCouponUser(
             user_id = 1,
             coupon_id = 1,
             status = 0,
     )
     await  e1.save()
     e2 = await model.LitemallCouponUser.find_by(id = e1.id)
     self.assertEqual(e1.id, e2.id)
コード例 #2
0
 async def test_update(self):
     e1 = model.LitemallCouponUser(
         user_id = 2,
         coupon_id = 1,
         status = 0,
     )
     await  e1.save()
     e1 = await  model.LitemallCouponUser.find_by(user_id = 2)
     e1.status = 1
     await e1.save()
     e2 = await model.LitemallCouponUser.find_by(id = e1.id)
     self.assertEqual(e2.status, 1)
コード例 #3
0
import asyncio
import orm
import model

loop = asyncio.get_event_loop()

sql_config = dict(
    host='localhost',
    port=3306,
    user='******',
    password='******',
    db='itemmail',
    charset='utf8',
    autocommit=True,
    maxsize=10,
    minsize=1,
)

loop.run_until_complete(orm.conn.connection(loop=loop, **sql_config))

e1 = model.LitemallCouponUser(
    user_id=1,
    coupon_id=1,
    status=0,
)
loop = asyncio.get_event_loop()
loop.run_until_complete(e1.save())