This plugin is an HTML5 Web SQL polyfill for Windows Phone 8+ Apache Cordova applications.
-
HTML5 Web SQL syntax and semantics
- With the excepton of
window.openDatabaseanddb.closebeing asyncronous, accepting callbacks for success and error.
- With the excepton of
-
Multiple opened databases and outstanding transactions
-
Full support for nesting
executeSqlin a trasaction-
Combine nested and non-nested
executeSqlcalls in a single transaction. -
Data and error callbacks allow further
executeSqlcalls to be made from within them. -
The data callabck returns a
resultSetwithitems,rowsAffectedandinsertId. -
The error callabck allows cancelling the rollback by returning
false.
-
-
Versioning support
-
Version argument is enforced in
window.openDatabse- If the databse exists, method fail if requested version is wrong.
- If it doesn't, a new one is created and assigned the requrested version.
- Version argument can be an empty string
''- If the databse exists, in any version, will open and set the version.
- If it doesn't, will create a new one with version '0.0'.
-
Databse version is availbale via
db.versionproperty. -
Support for transactional version changes via
db.changeVersion.
-
-
Tests and Examples (Cordova-SQLitePlugin-WP-Examples)
-
Fully working example project using Apache Cordova command line
-
Fully working example project using manual installation
-
Extensive Jasmine 2.0 based test suite
-
You can install the plugin using the Apache Cordova command line or manually.
Assuming you have installed the Apache Cordova cli, created a cordova project and added the wp8 platform (see Apache Cordova command-line interface docs), cd to the Cordova project root and run:
cordvova plugins add Cordova-SQLitePlugin-WP-
Create a Cordova wp8 Visual Studio project using the wizard (see Apache Cordova's Windows Phone 8 Platform Guide).
-
Clone this repository or download a ziped vesrion and unzip it.
-
Copy the
src/wp/*.csto your Visual Studio project directory. -
Add the
www/*.jsto your www directory. -
Add the below xml fragment to your
config.xmlfile
<config-file target="config.xml" parent="/*">
<feature name="SQLitePlugin">
<param name="wp-package" value="SQLitePlugin"/>
</feature>
</config-file>Working examples for both a manual constrcted and cli based projects are available at Cordova-SQLitePlugin-WP-Examples.
Once the plugin is installed, the following jasmine 2.0 test should succeed:
it('sould allow crud and database managment scripts', function (done) {
window.openDatabase('name', '1.0', 'desc', 1024 * 1024 * 5, function (db) {
db.transaction(
function (tx) {
tx.executeSql('CREATE TABLE t(x INTEGER PRIMARY KEY ASC, yy TEXT, zz INTEGER)');
tx.executeSql('DROP TABLE t');
tx.executeSql('CREATE TABLE t(x INTEGER PRIMARY KEY ASC, y TEXT, z INTEGER, k INTEGER)');
tx.executeSql('INSERT INTO t (y, z, k) VALUES("y", 7, 2)');
tx.executeSql('INSERT INTO t (y, z, k) VALUES("y1", 71, 105)');
tx.executeSql('SELECT COUNT(x) as c FROM t', [], function (t, rs) {
expect(rs.rows.length).toBe(1);
var item = rs.rows.item(0);
expect(item['c']).toBe(2);
done();
});
},
function (err) {
expect('Unexpected error ' + JSON.stringify(err)).toBeUndefined();
done();
});
});
});Copyright (c) 2014 Welldone Software Solutions 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.