https://github.com/sdesalas/websqldump
An ultra-light JS library for exporting data out of WebSQL
https://github.com/sdesalas/websqldump
dump websql
Last synced: about 2 months ago
JSON representation
An ultra-light JS library for exporting data out of WebSQL
- Host: GitHub
- URL: https://github.com/sdesalas/websqldump
- Owner: sdesalas
- License: mit
- Created: 2016-01-22T14:12:06.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-11-02T18:38:40.000Z (over 5 years ago)
- Last Synced: 2025-03-18T05:43:57.377Z (about 2 months ago)
- Topics: dump, websql
- Language: JavaScript
- Homepage:
- Size: 892 KB
- Stars: 38
- Watchers: 3
- Forks: 14
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.MIT
Awesome Lists containing this project
README

An ultra-light JS library for exporting data out of WebSQL
## Usage
```
// 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
}
});
```### Export options
- **database**: Required. The name of the database to export
- **table**: The table to export, if undefined then all tables are exported (defaults to undefined)
- **version**: The version of the web database (defaults to '1.0')
- **dbsize**: The size of the database in bytes (defaults to 5 * 1024 * 1024 - ie 5MB)
- **linebreaks**: Set to true to add line-breaks (defaults to false)
- **schemaonly**: Set to true to get the schema only (defaults to false)
- **dataonly**: Set to true to get the data only (defaults to false)
- **success**: Callback with 1 parameter (sql output). If not available will output to console.
- **error**: Callback with 1 parameter (err message). If not available on error will throw an exception.### Dependencies
No JavaScript library dependencies. Requires browser with HTML5 WebSql support (such as WebKit browsers like chrome and safari) or equivalent `openDatabase` polyfill.
### Demo
The following page contains a test harness:
[http://sdesalas.github.io/websqldump](http://sdesalas.github.io/websqldump)
You will need to create some tables and enter data in order for the demo to become meaningful.