import orm
import asyncio
from models import User, Blog, Comment
async def init(loop):
await orm.create_pool(loop=loop,user='www-data', password='www-data', db='awesome',host='xxx.xxx.xxx.xxx')
u = User(name='Test', email='test@example.com', passwd='1234567890', image='about:blank')
await u.save()
loop = asyncio.get_event_loop()
tasks = [init(loop)]
loop.run_until_complete(asyncio.wait(tasks))
Sign in to make a reply
用户7642543399
import orm
import asyncio
from models import User, Blog, Comment
async def init(loop):
await orm.create_pool(loop=loop,user='www-data', password='www-data', db='awesome',host='xxx.xxx.xxx.xxx')
u = User(name='Test', email='test@example.com', passwd='1234567890', image='about:blank')
await u.save()
loop = asyncio.get_event_loop()
tasks = [init(loop)]
loop.run_until_complete(asyncio.wait(tasks))