aiomysql依赖于pymysql ,“_auth”是pymysql的模块。需要检查一下自己的pymysql版本,更新为最新的版本,一般不会出问题:
引入aiomysql:
async def main(loop):
# 初始化数据库连接池
pool = await aiomysql.create_pool(host='127.0.0.1', port=3306,
user='root', password='123456',
db='article', loop=loop, charset="utf8", autocommit=True)
async with aiohttp.ClientSession() as session:
html = await featch(start_url, session)
seen_urls.add(start_url)
extract_html(html)
asyncio.ensure_future(consumer(pool))
if __name__ == '__main__':
loop = asyncio.get_event_loop()
asyncio.ensure_future(main(loop))
loop.run_forever()