Hi,
Iam new to developing HTML5 applications. In this I want to insert 1000's of records into sqlite database using HTML5. This process is very slow. How to use BEGIN/COMMIT before inserting records. In this way to speed up the insertions. Please guide me anybody. Thanks in advance. Please run this example in chrome browser. This is the code for your reference:
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
var msg;
//db.transaction(function(tx){tx.executeSql("BEGIN",[]);});
for(var i=0;i<1000;i++)
{
txquer(i,"test");
}
//db.transaction(function(tx){tx.executeSql("COMMIT",[]);});
db.transaction(function (tx) {
tx.executeSql('SELECT * FROM LOGS', [], function (tx, results) {
var len = results.rows.length, i;
msg = "<p>Found rows: " + len + "</p>";
document.querySelector('#status').innerHTML += msg;
}, null);
});
function txquer(i,test)
{
db.transaction(
function(tx){
tx.executeSql('INSERT INTO LOGS (id, log) VALUES (?, ?)',[i,test]);
}
);
}
</script>
</head>
<body>
<div id="status" name="status">Status Message</div>
</body>
</html>
Regards, Neeraja.