Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
uk.co.workingedge.cordova.plugin.sqliteporter
Advanced tools
Enables importing/exporting of SQLite databases to/from JSON/SQL.
This Cordova/Phonegap plugin can be used to import/export to/from a SQLite database using either SQL or JSON.
Usage scenarios
$ cordova plugin add uk.co.workingedge.cordova.plugin.sqliteporter
$ phonegap plugin add uk.co.workingedge.cordova.plugin.sqliteporter
$ plugman install --plugin=uk.co.workingedge.cordova.plugin.sqliteporter --platform=<platform> --project=<project_path> --plugins_dir=plugins
For example, to install for the Android platform
$ plugman install --plugin=uk.co.workingedge.cordova.plugin.sqliteporter --platform=android --project=platforms/android --plugins_dir=plugins
Add the following xml to your config.xml to use the latest version of this plugin from plugins.cordova.io:
<gap:plugin name="uk.co.workingedge.cordova.plugin.sqliteporter" source="plugins.cordova.io" />
or from npmjs.com:
<gap:plugin name="uk.co.workingedge.cordova.plugin.sqliteporter" source="npm" />
The plugin is exposed via the cordova.plugins.sqlitePorter
object and provides the following functions:
Executes a set of SQL statements against the defined database. Can be used to import data defined in the SQL statements into the database, and may additionally include commands to create the table structure.
cordova.plugins.sqlitePorter.importSqlToDb(db, sql, opts);
Create a database from a SQL dump
var db = window.openDatabase("Test", "1.0", "TestDB", 1 * 1024);
var sql = "CREATE TABLE Artist ([Id] PRIMARY KEY, [Title]);"+
"INSERT INTO Artist(Id,Title) VALUES ('1','Fred');";
var successFn = function(count){
alert("Successfully imported "+count+" SQL statements to DB");
};
var errorFn = function(error){
alert("The following error occurred: "+error.message);
};
var progressFn = function(current, total){
console.log("Imported "+current+"/"+total+" statements";
};
cordova.plugins.sqlitePorter.importSqlToDb(db, sql, {
successFn: successFn,
errorFn: errorFn,
progressFn: progressFn
});
Update an existing database
var db = window.openDatabase("Test", "1.0", "TestDB", 1 * 1024);
var sql = "INSERT INTO Artist(Id,Title) VALUES ('6','Jane');"+
"UPDATE Artist SET Title='Susan' WHERE Id='2';"+
"DELETE FROM Artist WHERE Id='5';";
var successFn = function(count){
alert("Successfully imported "+count+" SQL statements to DB");
};
var errorFn = function(error){
alert("The following error occurred: "+error.message);
};
var progressFn = function(current, total){
console.log("Imported "+current+"/"+total+" statements";
};
cordova.plugins.sqlitePorter.importSqlToDb(db, sql, {
successFn: successFn,
errorFn: errorFn,
progressFn: progressFn
});
Exports a SQLite DB as a set of SQL statements.
cordova.plugins.sqlitePorter.exportDbToSql(db, opts);
var db = window.openDatabase("Test", "1.0", "TestDB", 1 * 1024);
var successFn = function(sql, count){
console.log("Exported SQL: "+sql);
alert("Exported SQL contains "+count+" statements");
};
cordova.plugins.sqlitePorter.exportDbToSql(db, {
successFn: successFn
});
Converts table structure and/or row data contained within a JSON structure into SQL statements that can be executed against a SQLite database. Can be used to import data into the database and/or create the table structure.
cordova.plugins.sqlitePorter.importJsonToDb(db, json, opts);
Create a database from a SQL dump
var db = window.openDatabase("Test", "1.0", "TestDB", 1 * 1024);
var json = {
"structure":{
"tables":{
"Artist":"([Id] PRIMARY KEY, [Title])"
},
"otherSQL": [
"CREATE UNIQUE INDEX Artist_ID ON Artist(Id)"
]
},
"data":{
"inserts":{
"Artist":[
{
"Id":"1",
"Title":"Fred"
}
]
}
}
};
var successFn = function(count){
alert("Successfully imported JSON to DB; equivalent to "+count+" SQL statements");
};
var errorFn = function(error){
alert("The following error occurred: "+error.message);
};
var progressFn = function(current, total){
console.log("Imported "+current+"/"+total+" statements";
};
cordova.plugins.sqlitePorter.importJsonToDb(db, json, {
successFn: successFn,
errorFn: errorFn,
progressFn: progressFn
});
Update an existing database
var db = window.openDatabase("Test", "1.0", "TestDB", 1 * 1024);
var json = {
"data":{
"inserts":{
"Artist":[
{
"Id":"1",
"Title":"Fred"
}
]
},
"updates":{
"Artist":[
{
"set":
{
"Title":"Susan"
},
"where":
{
"Id":"2"
}
}
]
},
"deletes":{
"Artist":[
{
"Id":"5"
}
]
}
}
}
};
var successFn = function(count){
alert("Successfully imported JSON to DB; equivalent to "+count+" SQL statements");
};
var errorFn = function(error){
alert("The following error occurred: "+error.message);
};
var progressFn = function(current, total){
console.log("Imported "+current+"/"+total+" statements";
};
cordova.plugins.sqlitePorter.importJsonToDb(db, json, {
successFn: successFn,
errorFn: errorFn,
progressFn: progressFn
});
Exports a SQLite DB as a JSON structure
cordova.plugins.sqlitePorter.exportDbToJson(db, opts);
var db = window.openDatabase("Test", "1.0", "TestDB", 1 * 1024);
var successFn = function(json, count){
console.log("Exported JSON: "+json);
alert("Exported JSON contains equivalent of "+count+" SQL statements");
};
cordova.plugins.sqlitePorter.exportDbToSql(db, {
successFn: successFn
});
Wipes all data from a database by dropping all existing tables.
cordova.plugins.sqlitePorter.wipeData(db, opts);
var db = window.openDatabase("Test", "1.0", "TestDB", 1 * 1024);
var successFn = function(count){
alert("Successfully wiped "+count+" tables");
};
var errorFn = function(error){
alert("The following error occurred: "+error.message);
};
var progressFn = function(current, total){
console.log("Wiped "+current+"/"+total+" tables";
};
cordova.plugins.sqlitePorter.wipeData(db, {
successFn: successFn,
errorFn: errorFn,
progressFn: progressFn
});
https://github.com/dpa99c/cordova-sqlite-porter-example
This example project illustrates how the plugin can be used to import/export data from a WebSQL database in the WebView.
https://github.com/dpa99c/cordova-sqlite-porter-example-native-plugin
This example project illustrates how the plugin can be used to import/export data from a native SQLite database using a native SQLite plugin
The MIT License
Copyright (c) 2015 Working Edge Ltd.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Enables importing/exporting of SQLite databases to/from JSON/SQL.
The npm package uk.co.workingedge.cordova.plugin.sqliteporter receives a total of 307 weekly downloads. As such, uk.co.workingedge.cordova.plugin.sqliteporter popularity was classified as not popular.
We found that uk.co.workingedge.cordova.plugin.sqliteporter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.