Thanks as in my case just number 2 is possible a quite 'silly' question:
How do you normally check if Update was successful if the specified row did not exists.

e.g: UPDATE MyTable SET Account='MyAccountName' WHERE ID=50

If row 50 does not exists it does nothing and I seem not to get any return to 
know?

using pysqlite.

Thanks W.Braun



A. Pagaltzis wrote:
* Mag. Wilhelm Braun <[EMAIL PROTECTED]> [2007-12-25 15:10]:
QUESTION: is there a better way to make this important
decision? using Sqlite

1. If you are changing the entire row on every update, you can
   simply use `INSERT OR REPLACE` (assuming there is a UNIQUE
   column) to always do this in a single query.

   See <http://sqlite.org/lang_conflict.html>.

2. If you only want to update some of the columns, particularly
   if you are likely to update rows several times, you can use
   `UPDATE` to try and update, and if this did not affect any
   rows you do an `INSERT`.

In #1, you always get the job done with a single query. In #2,
you are usually done after the first but sometimes need a second.
Both are more efficient than your current approach, which always
runs two queries.

Regards,

Reply via email to