I delete data on the Internet with the Google Chrome extension. I store them in a multidimensional array. I want to save all the data in a Sqlite database.
I am reading this page How to speed up the process of inserting 1000's of records in sqlite using HTML5 , but the answer does not seem to work.
When I open a transaction for each INSERT , it works
i=0; while(i<n){ (function(aa){ db.transaction(function (tx) { tx.executeSql("INSERT INTO Links2 (c1, c2, c3, c4, c5, c6) VALUES ('"+aa[0]+"', "+parseInt(aa[1])+", '"+parseInt(aa[2])+"', '"+aa[3]+"', '"+aa[4]+"', '"+aa[5]+"')"); }); })(myDataArray[i]); i++; }
The problem is when I try to open a transaction before Bye
db.transaction(function (tx) { i=0; while(i<n){ aa = myDataArray[i]; txquer(tx, i, aa[0], parseInt(aa[1]), parseInt(aa[2]), aa[3], aa[4], aa[5]); i++; } }); function txquer(tx,i,a,b,c,d,e,f){ console.log("INSERT INTO Links2 (c1, c2, c3, c4, c5, c6) VALUES ('"+a+"', "+b+", '"+c+"', '"+d+"', '"+e+"', '"+f+"')"); tx.executeSql("INSERT INTO Links2 (c1, c2, c3, c4, c5, c6) VALUES ('"+a+"', "+b+", '"+c+"', '"+d+"', '"+e+"', '"+f+"')"); }
When I individually test each console.log output, I work. But the script does not save data in the database.