Use Client.execute_with_progress(query) to run a query while monitoring its progress. This method returns an asynchronous iterator that yields (num_rows, total_rows).
To retrieve the actual result of the query after the iterator is exhausted, call await progress.get_result() within an else block of the async for loop to ensure the query completed successfully.
from aioch import Client
import asyncio
async def exec_progress():
client = Client('localhost')
# Returns an async iterator yielding (num_rows, total_rows)
progress = await client.execute_with_progress('SELECT * FROM my_table')
async for num_rows, total_rows in progress:
print(f"Progress: {num_rows}/{total_rows}")
else:
# Retrieve the result after completion
rv = await progress.get_result()
print(rv)
asyncio.run(exec_progress())