Discuss / Python / 编写数据访问代码【修正】【python3.10】

编写数据访问代码【修正】【python3.10】

Topic source

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))


  • 1

Reply