An ultra-light JS library for exporting data out of WebSQL
An ultra-light JS library for exporting data out of WebSQL
// Export whole db to console
websqldump.export({
database: 'NorthwindLite'
});
// Export database data and POST to remote server
websqldump.export({
database: 'NorthwindLite',
dataonly: true,
linebreaks: true,
success: function(sql) {
$.ajax({type: 'POST', url: 'http://myserver.com/sync', data: {clientId: '4EAB0319', localdb: sql});
}
});
// Export single table (schema only) to alert window, ignore errors
websqldump.export({
database: 'NorthwindLite',
table: 'Orders',
schemaonly: true,
linebreaks: true,
success: function(sql) {
alert(sql);
},
error: function(msg) {
// do nothing
}
});
No JavaScript library dependencies. Requires browser with HTML5 WebSql support (such as WebKit browsers like chrome and safari) or equivalent openDatabase
polyfill.
The following page contains a test harness:
http://sdesalas.github.io/websqldump
You will need to create some tables and enter data in order for the demo to become meaningful.