Skip to content

Instantly share code, notes, and snippets.

@xarg
Created March 3, 2015 16:27
Show Gist options
  • Save xarg/c3869f9f68dc226e0751 to your computer and use it in GitHub Desktop.
Save xarg/c3869f9f68dc226e0751 to your computer and use it in GitHub Desktop.
WebSQL to jSON dump
//change table variables below according to your case and you should get a nice JSON at the end
var db = "db";
var table = "your_table";
var db = openDatabase(db, '1.0.0', '', 2 * 1024 * 1024);
db.transaction(function (tx) {
var l = [];
tx.executeSql('select * from ' + table, null, function(tx, res){
for (var i = 0; i < res.rows.length; i++) {
l.push(res.rows.item(i));
}
console.log(JSON.stringify(l, null, '\t'));
})
})
Copy link

ghost commented Jul 10, 2018

Great!! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment