Skip to content

Commit 2aebc5f

Browse files
committed
Add execution progress section to README
1 parent f0f7fb6 commit 2aebc5f

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,36 @@ The `Store` class supports the following options:
9999
Use `Store.for_download()` as a convenient shorthand for storing results
100100
as a single Parquet file with a presigned URL.
101101

102+
### Execution progress
103+
104+
You can monitor the progress of running queries by registering a
105+
progress handler on the connection. This follows the
106+
[`sqlite3.Connection.set_progress_handler()`](https://docs.python.org/3/library/sqlite3.html#sqlite3.Connection.set_progress_handler)
107+
pattern.
108+
109+
```python
110+
from wherobots.db import connect, ProgressInfo
111+
from wherobots.db.region import Region
112+
from wherobots.db.runtime import Runtime
113+
114+
def on_progress(info: ProgressInfo) -> None:
115+
print(f"{info.tasks_completed}/{info.tasks_total} tasks "
116+
f"({info.tasks_active} active)")
117+
118+
with connect(
119+
api_key='...',
120+
runtime=Runtime.TINY,
121+
region=Region.AWS_US_WEST_2) as conn:
122+
conn.set_progress_handler(on_progress)
123+
curr = conn.cursor()
124+
curr.execute("SELECT ...")
125+
results = curr.fetchall()
126+
```
127+
128+
The handler receives a `ProgressInfo` named tuple with `execution_id`,
129+
`tasks_total`, `tasks_completed`, and `tasks_active` fields. Pass
130+
`None` to `set_progress_handler()` to disable progress reporting.
131+
102132
### Runtime and region selection
103133

104134
You can chose the Wherobots runtime you want to use using the `runtime`

0 commit comments

Comments
 (0)