Python aimySQL如何在fetchone()上迭代

Python aimySQL如何在fetchone()上迭代,python,python-asyncio,aio-mysql,Python,Python Asyncio,Aio Mysql,aimySQL如何使用fetchone()对结果进行迭代。我使用sames代码作为aimysql用于fetchall()的代码 我在wait cursor.fetchone()中遇到了一个for r的问题,它不断地将每一列分解成自己的行 我的google fu未能找到和提供示例。所有fetchone()示例都显示仅获取一行,或者sql命令中的限制为1 # Not going to show how to connect to a sql # Connect with Pool async wi

aimySQL如何使用fetchone()对结果进行迭代。我使用sames代码作为aimysql用于fetchall()的代码

我在wait cursor.fetchone()中遇到了一个for r的问题,它不断地将每一列分解成自己的行

我的google fu未能找到和提供示例。所有fetchone()示例都显示仅获取一行,或者sql命令中的限制为1

# Not going to show how to connect to a sql

# Connect with Pool
async with db.pool.acquire() as conn:

    # Get a cursor
    async with conn.cursor() as cursor:

        # Run the SQL Command
        await cursor.execute(sql)

        # Get the column names for the result
        columns = [column[0] for column in cursor.description]
      
        # https://github.com/aio-libs/aiomysql/blob/master/aiomysql/cursors.py
        # using example from async def fetchall(self): ~line 635

        while True:
            row = await cursor.fetchone()

            # If no results break out of loop
            if row is None:
                break

            # Print the row as a list\tuple
            print(row)

            # Convert Result to a dict with column labels 
            r = dict(zip(columns,row))
            print(r)