Registry /
database / uk.co.workingedge.cordova.plugin.sqliteporter
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
sqlitePorter
✓ import { sqlitePorter } from 'uk.co.workingedge.cordova.plugin.sqliteporter';
✗ var sqlitePorter = require('uk.co.workingedge.cordova.plugin.sqliteporter');
ESM import works with bundlers. CommonJS require may not work in all environments; use ESM for consistency.
sqlitePorter.importSqlToDb
✓ sqlitePorter.importSqlToDb(db, sql);
✗ window.sqlitePorter.importSqlToDb(db, sql);
Access as named export, not via window object. The plugin is available after deviceready.
sqlitePorter.exportDbToSql
✓ sqlitePorter.exportDbToSql(db);
✗ sqlitePorter.exportDbToSql(db, {});
Second parameter is optional options object, but exporting without it is valid.
Basic usage demonstrating import/export of SQL and JSON with native SQLite database in a Cordova app.
import { sqlitePorter } from 'uk.co.workingedge.cordova.plugin.sqliteporter';
import { SQLite } from 'cordova-sqlite-storage';
// Wait for deviceready
document.addEventListener('deviceready', async () => {
try {
const db = await SQLite.openDatabase({ name: 'test.db', location: 'default' });
// Import SQL
const sql = 'CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT);\nINSERT INTO users VALUES (1, \'Alice\');';
await sqlitePorter.importSqlToDb(db, sql);
// Export to SQL
const exported = await sqlitePorter.exportDbToSql(db);
console.log(exported);
// Export to JSON
const json = await sqlitePorter.exportDbToJson(db);
console.log(json);
// Import JSON
const jsonData = { 'users': [{ 'id': 2, 'name': 'Bob' }] };
await sqlitePorter.importJsonToDb(db, jsonData);
} catch (error) {
console.error('SQLite Porter error:', error);
}
});
Errors
Common errors & fixes
sqlitePorter is not defined
Accessing sqlitePorter before 'deviceready' event or using CommonJS require in ESM environment.
fixUse ESM import and ensure code runs after deviceready.
Cannot read property 'importSqlToDb' of undefined
Import path incorrect or plugin not installed correctly.
fixCheck installation with 'cordova plugin list' and import as 'import { sqlitePorter } from 'uk.co.workingedge.cordova.plugin.sqliteporter'' No SQLite database found
Database not opened via cordova-sqlite-storage or using HTML5 WebSQL when not available.
fixOpen a valid HTML5 WebSQL or native SQLite database first.
SyntaxError: Unexpected token IN SERT
SQL string contains typos or malformed statements.
fixValidate SQL syntax; ensure each statement ends with semicolon and no stray newlines.
Audit
Dependencies
cordova-sqlite-storageoptionalRequired for native SQLite support on platforms without WebSQL or for unlimited storage