Registry / database / cordova-sqlite-ext

cordova-sqlite-ext

JSON →
library7.0.0jsnpmunverified

Cordova SQLite Ext (v7.0.0) provides a native SQLite interface for Cordova/PhoneGap apps with extra features like BASE64, REGEXP, and pre-populated databases. It supports Android, iOS, macOS, and Windows 10 (UWP). Based on the HTML5 Web SQL API, it addresses the multiple SQLite corruption issue and has breaking changes in upcoming major releases. Compared to the core cordova-sqlite-storage plugin, this version adds REGEXP and BASE64 support. The plugin uses a before_plugin_install hook to fetch dependencies from npm. MIT licensed with Apache 2.0 option on Android/Windows. Not heavily maintained; consider alternatives for new projects.

npm install cordova-sqlite-ext
INSTALL
IMPORT
SIG · CORDOVA-SQLITE-EXT
C
cordova-sqlite-ext
databasejavascriptv7.0.0
harness data pending
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.

window.sqlitePlugin
var sqlitePlugin = window.sqlitePlugin;
import sqlitePlugin from 'cordova-sqlite-ext';
Plugin exposes itself as window.sqlitePlugin after device ready; no ES module import.
openDatabase
var db = window.sqlitePlugin.openDatabase({name: 'my.db', location: 'default'});
var db = openDatabase('my.db', '1.0', 'description', 50000);
OpenDatabase is a method on sqlitePlugin object, not the global Web SQL function. Location must be 'default' instead of numeric values since breaking changes.
SQLResultSet
db.transaction(function(tx) { tx.executeSql('SELECT ?', [1], function(tx, results) { console.log(results.rows.length); }); });
var results = db.executeSql('SELECT 1');
Queries are executed inside transactions; executeSql is asynchronous with callbacks, not synchronous.

Shows basic database creation, table creation, insert, and select inside a transaction using the plugin API after device ready.

// Wait for device ready document.addEventListener('deviceready', function() { var db = window.sqlitePlugin.openDatabase({ name: 'mydb.sqlite', location: 'default' }); db.transaction(function(tx) { tx.executeSql('CREATE TABLE IF NOT EXISTS test (id integer primary key, value text)'); tx.executeSql('INSERT INTO test VALUES (?, ?)', [1, 'test'], function(tx, res) { console.log('insertId: ' + res.insertId + ' rowsAffected: ' + res.rowsAffected); }); tx.executeSql('SELECT * FROM test', [], function(tx, res) { var len = res.rows.length; for (var i = 0; i < len; i++) { var row = res.rows.item(i); console.log('Row: ' + row.id + ' ' + row.value); } alert('Query completed'); }); }, function(err) { console.log('Transaction ERROR: ' + err.message); }); });
Debug
Known issues
breakingMultiple SQLite corruption problem - see GitHub issue #626
fix
Use latest version and consider androidDatabaseProvider: 'system' on Android to reduce risk.
affects: all
breakingError code will always be 0 in upcoming major release; actual SQLite3 error code in message
fix
Do not rely on error.code for logic; parse error.message instead.
affects: <8.0.0
deprecatedLocation numeric values (0-2) deprecated, use 'default' or iosDatabaseLocation
fix
Replace location:0 with location:'default' or iosDatabaseLocation:'default'.
affects: >=4.0.0
gotchaandroidLockWorkaround:1 may cause issues; only use if needed
fix
Omit androidLockWorkaround unless necessary; prefer androidDatabaseProvider: 'system'.
affects: all
Errors
Common errors & fixes
Error: No sqlitePlugin found
Code runs before deviceready event or plugin not installed properly
fix
Wait for deviceready event and verify plugin installation with cordova plugin list.
TypeError: Cannot read property 'openDatabase' of undefined
window.sqlitePlugin not available yet
fix
Ensure all SQLite calls are inside deviceready callback.
cordova plugin add cordova-sqlite-ext fails with npm error
Missing dependencies or network issue during before_plugin_install hook
fix
Manually run npm install cordova-sqlite-ext-deps in the plugin directory or use --nofetch.
Upgrade
Version history
7.0.0latest on npm
Audit
Dependencies
cordova-sqlite-ext-depsoptionalInstalled via before_plugin_install hook for SQLite3 libraries
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
cordova-sqlite-ext — npm install cordova-sqlite-ext · libregistry