from Util.MySQLUtil import init_mysql_pool async def main(): mysql_pool = await init_mysql_pool() async with mysql_pool.acquire() as conn: await conn.ping() async with conn.cursor() as cur: # 查询获取所有知识点 await cur.execute(""" SELECT id, title, parent_id, is_leaf FROM knowledge_points ORDER BY parent_id, id """) rows = await cur.fetchall() print(rows) if __name__ == '__main__': import asyncio asyncio.run(main())