Skip to content

Instantly share code, notes, and snippets.

@rascoop
Created February 11, 2014 21:02
Show Gist options
  • Save rascoop/8944080 to your computer and use it in GitHub Desktop.
Save rascoop/8944080 to your computer and use it in GitHub Desktop.
Export WebSQL to CSV Locally with force download - http://stackoverflow.com/questions/9279664/export-websql-to-csv-locally
testCSV = function(){
var csvData = "";
db.transaction(function(tx){
tx.executeSql('SELECT * FROM grocery', [], function (tx, results){
var len = results.rows.length, i;
for (i = 1; i < len; i++) {
csvData += results.rows.item(i).itemno + "," + results.rows.item(i).quantity + "\n";
}
window.location='data:application/webcsv;charset=utf8,' + encodeURIComponent(csvData);
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment