Q:

sqlite3: multiple updates in one transaction

I've learned how to put multiple INSERTs into one transaction using SELECT UNION as in this example
var newQuery = true, query = '';
for (i=0; i<locations_length; i++) {
    if (newQuery) {
        query = 'INSERT INTO myTable (id, name, code)';
        newQuery = false;
    }
    else {
        query += ' UNION';
    }

    query += ' SELECT "'+values[i][0]+'", "'+values[i][1]+'", "'+values[i][2]+'"';

    if (i!=0 && i%499==0) {
        db.execute(query);
        newQuery = true;
    }
}

but it doesn't seem to work for multiple UPDATEs.
Is there any way I can put multiple UPDATEs into one transaction?
Also, is there a way to put mixture of INSERTs and UPDATEs into one transaction?
I'm working with Python 2.7 by the way.
Thank you so much in advance.

A:

Use BEGIN TRANSACTION and COMMIT or ROLLBACK and you can make any number of statements occur in a single transaction.
http://www.sqlite.org/lang_transaction.html

