On Tue, 25 Dec 2007 19:24:48 +0100, "Mag. Wilhelm Braun"
<[EMAIL PROTECTED]> wrote:

>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?

There is an SQLite function for that.
http://www.sqlite.org/c3ref/total_changes.html

>using pysqlite.

I don't know the pysqlite wrapper, but this may be of help:
http://www.initd.org/pub/software/pysqlite/doc/usage-guide.html
Search for "total_changes attribute".

>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,
>>   
-- 
  (  Kees Nuyt
  )
c[_]

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to