rogerbinns / apsw

Another Python SQLite wrapper
https://rogerbinns.github.io/apsw/
Other
739 stars 97 forks source link

query execution row and time limits #520

Open rogerbinns opened 6 months ago

rogerbinns commented 6 months ago

It would be nice to execute a query with row count and time limits. Row count is straight forward with an iterator wrapper.

For time limits it may be possible by doing something like:

I would be wise to implement #502 for the progress handler so multiple can co-exist.

Getting a monotonic clock is platform dependent. For python 3.13 there is an official API. For earlier releases the function py_get_monotonic_clock in the Python source Python/pytime.c has per platform headers and platform calls.

rogerbinns commented 6 months ago

This can be very hairy. For example the cursor iterator could be passed to another thread which would lose the context variable context.

The number of SQLite vm steps also matters in the progress callback since we want maybe tenth of a second granularity.