Discuss / Python / 下面是我的测试代码,可以测试成功。

下面是我的测试代码,可以测试成功。

Topic source
async def init(loop):
    pool = await orm.create_pool(loop, user='root', password='password', db='test')
    try:
        u = await user.find(100)
        print(u)
        u2 = user(id=100, name='alice')
        await u2.update()
        await u2.remove()
        await u2.save()

    except BaseException as e:
        logging.error('%s',e)
    else:
        logging.info('run ok')

    pool.close()
    await pool.wait_closed()

loop = asyncio.get_event_loop()
loop.run_until_complete(init(loop=loop))
loop.close()

  • 1

Reply