Hi all,

Many thanks for the info. I'll look into using the changes function for what
I need.

Cheers,
Dave


Ward Analytics Ltd - information in motion
Tel: +44 (0) 118 9740191
Fax: +44 (0) 118 9740192
www: http://www.ward-analytics.com

Registered office address: The Oriel, Sydenham Road, Guildford, Surrey,
United Kingdom, GU1 3SR
Registered company number: 3917021 Registered in England and Wales.

-----Original Message-----
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Simon Slavin
Sent: 24 April 2013 15:03
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Some basic questions


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

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

Reply via email to