On 23 Apr 2013, at 7:57pm, David Wellman <david.well...@ward-analytics.com> 
wrote:

> Q1) Is it possible to execute sql commands asynchronously ? i.e. my program
> issues the sql command and then 'loops' whilst waiting for the command to
> finish. The main need for this is so that my user has a chance to cancel the
> processing should they want to.

SQLite commands return with the data you requested.  There's no asynchronous 
mechanism.  You can implement one in threads or processes yourself, but it's 
almost never needed.  If your application performs any SQLite calls that take 
more than a couple of seconds, it's usually a sign that you didn't make the 
right indexes to let your SQL commands execute quickly.  Fix it by looking at 
your commands and figuring out what indexes they want, rather than by 
implementing multitasking.

The exception is for a SELECT command which returns multiple rows.  You step 
through the results row by bow by calling _step().  So after any initial 
sorting needed your program can just check to see whether the user has aborted 
yet before deciding to call _step() again, all without worrying about doing any 
asynchronous calls.  If the user choses to abort you just stop calling _step() 
and skip straight to the _finalize() to release any memory used by the query.

> Q2) For sql commands that do not return any data (really just the DML
> commands Update, Delete and Insert/Select) is there any way to find out how
> many rows were affected by the command? So if my Update command changes 57
> rows, then can I find that '57' number anywhere?

<http://www.sqlite.org/c3ref/changes.html>

If you don't have access to this function because you're using a non-SQLite 
database library you can find the same value using the SQL function "changes()":

<http://www.sqlite.org/lang_corefunc.html#changes>

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to