Created
March 3, 2015 16:27
-
-
Save xarg/c3869f9f68dc226e0751 to your computer and use it in GitHub Desktop.
WebSQL to jSON dump
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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')); | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great!! Thanks