Code Monkey home page Code Monkey logo

cordova-plugin-websql's Introduction

WebSQL plugin for Apache Cordova

Adds WebSQL functionality as Apache Cordova Plugin implemented on top of Csharp-Sqlite library. Support of Windows 8.0, Windows 8.1, Windows Phone 8.0 and Windows Phone 8.1.

Sample usage

Plugin follows WebDatabase specification, no special changes are required. The following sample code creates todo table (if not exist) and adds new record. Complete example is available here.

var dbSize = 5 * 1024 * 1024; // 5MB

var db = openDatabase("Todo", "", "Todo manager", dbSize, function() {
    console.log('db successfully opened or created');
});

db.transaction(function (tx) {
    tx.executeSql("CREATE TABLE IF NOT EXISTS todo(ID INTEGER PRIMARY KEY ASC, todo TEXT, added_on TEXT)",
        [], onSuccess, onError);
    tx.executeSql("INSERT INTO todo(todo, added_on) VALUES (?,?)", ['my todo item', new Date().toUTCString()], onSuccess, onError);
});

function onSuccess(transaction, resultSet) {
    console.log('Query completed: ' + JSON.stringify(resultSet));
}

function onError(transaction, error) {
    console.log('Query failed: ' + error.message);
}

Installation Instructions

Plugin is Apache Cordova CLI 3.x compliant.

  1. Make sure an up-to-date version of Node.js is installed, then type the following command to install the Cordova CLI:

     npm install -g cordova
    
  2. Create a project and add the platforms you want to support:

     cordova create sampleApp
     cd sampleApp
     cordova platform add windows <- support of Windows 8.0, Windows 8.1 and Windows Phone 8.1
     cordova platform add wp8 <- support of Windows Phone 8.0
    
  3. Add WebSql plugin to your project:

     cordova plugin add cordova-plugin-websql
    
  4. Build and run, for example:

     cordova build wp8
     cordova emulate wp8
    

To learn more, read Apache Cordova CLI Usage Guide.

Pre-populated DBs support

You can copy a prepared DB file to the App' LocalFolder on the first run, for example (in terms of the sample app):

initialize: function () {
    WinJS.Application.local.exists('Todo').done(
        function (found) {
            if (!found) {
                return copyStartData('Todo');
            }
        }
    );

    function copyStartData(copyfile) {
        return Windows.ApplicationModel.Package.current.installedLocation.getFolderAsync('www')
        .then(function (www) {
            return www.getFolderAsync('data')
            .then(function (data) {
                    return data.getFileAsync(copyfile).then(
                        function (file) {
                            if (file) {
                                return file.copyAsync(WinJS.Application.local.folder);
                            }
                        });
            });
        });
    }

    ...
},

The snippet copies www/data/Todo pre-populated DB to the App' local folder if it did not exist.

Based on this StackOverflow question.

Quirks

  • The display name, and size parameter values are not supported and will be ignored.

  • Due to SQLite limitations db version parameter to openDatabase and changeVersion methods should be an integer value or integer's string representation.

  • openDatabase on WP8 bypass version check by default. The reason of this is async nature of cordova calls to native APIs. To force version check and enable full versioning functionality set up the following variable:

    window.__webSqlUseSyncConstructor = true;
  • To use nested transactions you will need to pass parent transaction like this:

    var db = openDatabase('test1.db', '1.0', 'testLongTransaction', 2 * 1024);
    db.transaction(function (tx1) {
        tx1.executeSql('DROP TABLE IF EXISTS foo');
        tx1.executeSql('CREATE TABLE IF NOT EXISTS foo (id unique, text)');
        ...
        db.transaction(function (tx2) {
            tx2.executeSql('INSERT INTO foo (id, text) VALUES (1, "foobar")');
        }, null, null, null, null, false, tx1);
        ...
    }, null, null);

    tx1 passed as the last argument in the nested db.transaction refers to the parent transaction.

    Other arguments (null, null, null, null, false, tx1) are:

    • the db.transaction error callback,
    • the db.transaction success callback,
    • preflight operation callback,
    • postflight operation callback,
    • readOnly flag,
    • parent transaction - respectively.
  • To enable logging use:

    window.__webSqlDebugModeOn = true;

Copyrights

Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

cordova-plugin-websql's People

Contributors

jsoref avatar olivierbloch avatar panarasi avatar sgrebnov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-websql's Issues

Create Virtual Table Succed But table is not created

I'm trying to create a virtual table but even if the transaction is successful the table is not created this is the code I'm using:

db = openDatabase("trentXWB", "1.0", "Test DB", (10 * 1024 * 1024));
db.transaction(
	function (tx) { 
		tx.executeSql(
			"CREATE TABLE search_pages USING FTS3 ( id INTEGER NULL, title TEXT NULL, description TEXT NULL, body TEXT NULL, status TEXT NULL, template_id TEXT NULL, permalink TEXT NULL );", 
			[],
			function (tx, results) { console.log(tx); console.log(results); }, 
			function (tx, error) { console.log(tx); console.log(error); } 
		); 
	}
);

Cordova 6.5.0 (in stuck to this version by another plugin )
Windows 10 phone (Lumia 550)
Visual studio 2017

I'm doing something wrong or FTS is not supported?

Database does not open on [email protected]

I am developing an app using this plugin for some time now but after updating the Cordova CLI, the windows platform and the plugin to their last versions recently, the application stopped working - the database does not even open.
I am getting this JS console log:

device ready
openDatabase: name = jasenverkko
[Database] name: jasenverkko, lastTransactionId: 0. | new Database(); name = jasenverkko
[Database] name: jasenverkko, lastTransactionId: 0. | Database.open() err = {"description":"'SQLite' is undefined","number":-2146823279,"stack":"ReferenceError: 'SQLite' is undefined\n   at module.exports.getVersion (ms-appx://cz.pavelfidransky.bachelor/www/plugins/cordova-plugin-websql/src/windows/WebSqlProxy.js:23:13)\n   at module.exports (ms-appx://cz.pavelfidransky.bachelor/www/cordova.js:890:13)\n   at callback (ms-appx://cz.pavelfidransky.bachelor/www/plugins/cordova-plugin-websql/www/windows/Database.js:50:9)\n   at cordova.callbackFromNative (ms-appx://cz.pavelfidransky.bachelor/www/cordova.js:288:41)\n   at cordova.callbackSuccess (ms-appx://cz.pavelfidransky.bachelor/www/cordova.js:268:9)\n   at onSuccess (ms-appx://cz.pavelfidransky.bachelor/www/cordova.js:867:17)\n   at module.exports.open (ms-appx://cz.pavelfidransky.bachelor/www/plugins/cordova-plugin-websql/src/windows/WebSqlProxy.js:66:13)\n   at module.exports (ms-appx://cz.pavelfidransky.bachelor/www/cordova.js:890:13)\n   at Database (ms-a
[Database] name: jasenverkko, lastTransactionId: 0. | transaction
[Database] name: jasenverkko, lastTransactionId: 1. | transaction
database created
[SqlTransaction] id: 2, connectionId: undefined. | executeSql, ERROR: Connection is not set
[Database] name: jasenverkko, lastTransactionId: 2. | transaction.run callback error, lastTransactionId = 2; error: Error: Connection is not set
[SqlTransaction] id: 2, connectionId: undefined. | executeSql, ERROR: Connection is not set
SCRIPT5022: Unhandled exception at line 27, column 9 in ms-appx://cz.pavelfidransky.bachelor/www/plugins/cordova-plugin-websql/www/windows/SqlTransaction.js
0x800a139e - JavaScript runtime error: Connection is not set
File: SqlTransaction.js, Line: 27, Column: 9

It all worked well until the update. I haven't changed a single line of code: the database is opened after deviceready and all variables are set correctly.
I also tried to completely remove the plugin and the platform and add them back but it didn't help.

Tools and their versions used:
Cordova CLI: 5.0.0
Windows platform: 3.8.1
WebSQL plugin: 0.0.8
Visual Studio Express 2013
Windows 8.1 Pro

If there are any other information I need to supply, feel free to ask me.

Poor insert performance

We use this plugin on windows phone 8.1 (js project, non silverlight). The insert performance are poor (more than 10 times slower than on android (using native websql ) and ios ( using brodysoft plugin )).
Our database consists of a key/value store where the value is a Json blob.
It takes 40 second to save 700 record on a nokia 925. Grouping them by transaction of 100 record.
By transaction of 10 elements it take 65seconds. And by transaction of 400 it take less than 20 second but the db keep using all the cpu ressource after the success callback of the last transaction is called. Making other io failed (ajax queries).

I've tried grouping the insert using INSERT ... SELECT ... UNION ALL SELECT ...
without much improvement.

During this whole time the ui is frozen.

Is there some way to improve insert performance ?
by configuration maybe ? can we tune the sqlitedb with this plugin ?

Is this plugin is useable into webworkers to a least keep the ui responsive (i tried without success) ?

Thanks

Transactions & callbacks

Hi,
I have notice that transactions are not supported. Do you think it might be implemented in future versions?
Several frameworks use callbacks in transactions, but in your plugin at the moment this feature is not supported.
We understand that the problem is related to the previous question, but this feature would be useful to respect WebSql specification and therefore support frameworks like Sencha or jQuery.

Plugin Does Not Work in Windows 10

I'm studying Cordova, and recently I was testing the project on WIndows 10, but storing using WebSQL did not work.

So I researched and found this Plugin, but when running on Windows10 it does not work.

I noticed that the documentation says support for Windows 8 and 8.1.

I would like to know when we will support Windows 10 Universal Platform.

Thank you for your attention.

Windows 10 Support

Is it planned that this plugin will work on Windows 10 Universal Apps that are built with cordova and Visual Studio 2015?
Right now when I add the plugin and then run my project I get the following error:

Severity Code Description Project File Line Suppression State Error
Your project.json doesn't list 'win10' as a targeted runtime. You should add '"win10": { }' inside your "runtimes" section in your project.json, and then re-run NuGet restore.

Also, it states that the error occurs in Microsoft.NuGet.targets at line 211.

SQLite not defined

I am using cordova 3.8.0 with VS2013

Apache Cordova

Connecting to Device

Device is Ready

    </div>
    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript">
        document.addEventListener('deviceready', onDeviceReady, false);
        function onDeviceReady() {
            window.__webSqlDebugModeOn = true;
            var db = openDatabase('test1.db', '1.0', 'testLongTransaction', 2 * 1024);
            db.transaction(function (tx1) {
                tx1.executeSql('DROP TABLE IF EXISTS foo');
                tx1.executeSql('CREATE TABLE IF NOT EXISTS foo (id unique, text)');
                db.transaction(function (tx2) {
                    tx2.executeSql('INSERT INTO foo (id, text) VALUES (1, "foobar")');
                }, null, null, null, null, false, tx1);
            }, null, null);
        }
    </script>

Memory Leak ?

I'm using websql Plugin version 0.0.9 in Cordova 5.0.0 and platform "windows".
For performance tracking I use Windows Power Tools attached to either the emulator or the device.

In a readTransaction, when the success callback is invoked, you can see the used memory going up but I expect the memory to go down again once I've processed the result data and don't hold any refernce to it anymore. However, this is not the case, memory adds up each time I execute a readTransaction.
The transaction has one simple select query and I've set the result to null for testing where I would pass it to the cosuming function. Does the plugin maintain any kind of internal cache ?

Sql COUNT is notworking in Subqueries

COUNT is not working properly if it is inside a Sub query and the sub query uses outer table column to filter data

select (select count(*) from Cars where Cars.TypeID = CarTypes.TypeID) AS CarTypeCount
from CarTypes

As a temporary solution you can use IFNULL(SUM(1),0) AS MY_COUNT instead of COUNT(*) and it works. Hope this will be helpful for somebody like me.

MSBuidl.exe throws Error when Install this PLugin

Hi ,

I am facing a new issue which is not listed here, when I install all another plugin my project build, debug successfully but when I install this plugin, I got an error of MsBuild.exe and when I remove this plugin that error remains with the package... even after I clean the solution...

How to fix this, is there any other sqllite plugin to support Windows 8,8.1,10 ??

studio_error_1

Android 4.3 broken job

Hi, when i use my app in android 4.4 no problem at all but the same app in the Android 4.3 it often not working with global error message "the statment callback raised an exception or statment error callback did not return false" ... but some times it works!!?????

installation issues

Hi,

I have installed the plugin to the project, it has added sqlite.cs and websql.cs files. sqlite.cs has some sqlite references, where do i find these assemblies?

the assembly in the src folder under wp8 folder when opened in reflector says -
assembly: TargetFramework("Silverlight,Version=v4.0,Profile=WindowsPhone71", FrameworkDisplayName = "Silverlight 4.0 Windows Phone 7.1 Profile")

and throws the following error when you add it as a reference

A reference to a higher version or incompatible assembly cannot be added to the project.

changeVersion not supported

Is there any plan to add support to the changeVersion() method to set the version number of the schema?
Right now, calling code like db.changeVersion("1", "2") returns the following error:

0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'changeVersion'

Thanks!

[Windows][PhoneGap]Does nothing

Hi,

I'm using the command "phonegap serve" to communicate with my windows phone 8.1 and to test my application.

This application is using the plugin cordova-plugin-websql.

Everything is working on Android and IOS but nothing happens on Windows phone 8.1 (Not even errors) as i only tried to execute :

var dbSize = 5 * 1024 * 1024;
var db = openDatabase("dbName", "1.0","dbDesc", dbSize );

it just does not go any way further than this line and does not give any error.

Any thoughts ?

Thanks

PS : Everything is up-to-date

openDatabase callback doesnt work

The callback of the openDatabase function, the same one that is in the example, doesnt work on my deploy of windows phone. The only way that I have to know when the database is open is this one:

...
var dbSize = 5 * 1024 * 1024; // 5MB
// open database
app.db = openDatabase("Todo", "", "Todo manager", dbSize, function() {

    });
    setTimeout(function() {
        app.db.transaction(function (tx) {
            tx.executeSql("CREATE TABLE IF NOT EXISTS todo(ID INTEGER PRIMARY KEY ASC, todo TEXT, added_on DATETIME)", [], app.onSuccess, app.onError);
        });
    }, 1000);

...

No exception nor error is throw. I did the deploy in a Nokia 925, the cordova build didnt throw any error.

Getting 'Out of stack space' after 35 nested transaction

We are getting following error while executing multiple insert statement in a single transaction.

description : "Out of stack space"
message: "Out of stack space"
name: "Error"
number: -2146828260
stack : "Error: Out of stack space ...

We are getting this error on Windows 8.1 Pro (not windows mobile).

Please find the JS code to reproduce this issue from the following link

https://gist.github.com/shamsealam/4add6b2401c8eddb5ea1

Code follows the nested transaction format of windows 8.1 and not windows mobile.

We believe this to be resolved by increasing the thread size of native executeSQL method implementation

Error: Could not establish DB connection and apllication stuck in first page itself and in console im getting following log

'TaskHost.exe' (CoreCLR: DefaultDomain): Loaded 'C:\windows\system32\mscorlib.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Windows.RuntimeHost.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Windows.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Net.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Xml.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\Data\Programs{AA2A7970-2E3A-11E6-9AE2-35450EEB6EE9}\Install\com.handytrain.hometown.DLL'. Symbols loaded.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\Microsoft.Phone.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\Microsoft.Phone.Interop.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\WinMetadata\Windows.winmd'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Xml.Linq.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Core.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Adding feature.value=Device
Adding feature.value=Globalization
Adding feature.value=InAppBrowser
Adding feature.value=StatusBar
Adding feature.value=WebSql
Adding feature.value=DebugConsole
Adding feature.value=File
Adding feature.value=FileTransfer
Adding feature.value=SplashScreen
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\en-US\mscorlib.debug.resources.dll'. Module was built without symbols.
Exception thrown: 'System.IO.IsolatedStorage.IsolatedStorageException' in mscorlib.ni.dll
Updating IsolatedStorage for APP:DeviceID :: 30524cc3-de6a-4be2-91cd-e7cc9f87d4a7
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.ServiceModel.Web.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\windows\system32\System.Runtime.Serialization.ni.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
CordovaBrowser_LoadCompleted
Apache Cordova native platform version 3.8.2 is starting
Fading the splash screen in
Error::Plugin not allowed in config.xml. UniversalAnalytics
Error::Plugin not allowed in config.xml. UniversalAnalytics
platform android
open db ,1.0
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:\Data\Programs{AA2A7970-2E3A-11E6-9AE2-35450EEB6EE9}\Install\Community.CsharpSqlite.WinPhone.DLL'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
DB versions same
success in check db
platform android
open db 1.0
DB versions same
success in check db
Error in Success callbackId: WebSql308972083 : Error: Could not establish DB connection
Error in Success callbackId: WebSql308972083 : Error: Could not establish DB connection
Exception thrown: 'System.SystemException' in Microsoft.Phone.Interop.ni.dll
ERROR: Exception in InvokeScriptCallback :: An unknown error has occurred. Error: 80020101.
Failed to locate callback for id : WebSql308972083
The thread 0xf80 has exited with code 0 (0x0).
The thread 0xde0 has exited with code 0 (0x0).
The thread 0x6fc has exited with code 0 (0x0).
The thread 0xfc4 has exited with code 0 (0x0).
The thread 0xcc0 has exited with code 0 (0x0).
The thread 0x710 has exited with code 0 (0x0).
The thread 0x444 has exited with code 0 (0x0).
The thread 0x624 has exited with code 0 (0x0).
The thread 0xc3c has exited with code 0 (0x0).
The thread 0xa54 has exited with code 0 (0x0).
The thread 0xca0 has exited with code 0 (0x0).

too many projects in solution

Hi,

I am using Visual Studio for cordova, after upgrading websql plugin to 0.0.9, it reports an error which is 'too many projects in solution'. How can i cope with this? thanks!

Error occured while executing sql in Windows (Phone) 8.1

I am debugging Apache Cordova application in Visual Studio 2013.4. The application works fine in Ripple and Android emulator, however, when I try to debug on Windows x64 or Windows Phone (device) I get following error:

On this line: https://github.com/MSOpenTech/cordova-plugin-websql/blob/17015eb938d902eeb6018c03e438658103b28c17/www/windows/SqlTransaction.js#L105

Unhandled exception at line 105, column 9 in ms-appx://io.cordova.myapp.../www/plugins/com.msopentech.websql/www/windows/SqlTransaction.js

0x800a139e - JavaScript - runtime error [object Object]

Here is my code inside index.html in onDeviceReady function:

<script type="text/javascript">
    document.addEventListener("deviceready", onDeviceReady, false);

    var db = null;

    function onDeviceReady() {

        var dbSize = 5 * 1024 * 1024;
        // 5MB

        db = window.openDatabase("lilka", "1.0", "Lilka hybrid db", dbSize)
        if (db) {
            populateDatabase();
        }

    }

    function populateDatabase() {

        db.transaction(function(tx) {
                tx.executeSql("CREATE TABLE IF NOT EXISTS Product (Id INTEGER, Name TEXT)", [], onSuccess, onError);
                tx.executeSql("INSERT INTO Product(Id, Name) values (1, 'testvalue')", [], onSuccess, onError);

                tx.executeSql('SELECT * FROM Product', [], function(tx, results) {
                    var len = results.rows.length,
                        i;
                    for (i = 0; i < len; i++) {
                        alert(results.rows.item(i).Name);
                    }
                });
            )
        };
    }
</script>

I have found out that it fails while executing the CREATE TABLE IF NOT EXISTS.

Retrieved date types

Confused. Is this an issue or something I have missed?

On a Cordova 5, Windows 8.1 app using this plug in for sqlite I have a table which has a column:

Modified_Date Date Not Null

Now, when I save a date, say 1970/01/01 and retrieve the information this is returned:

/Date(0+0000)/

If I save the date 2015/06/16 and retrieve the information this is returned:

/Date(1434495600000+0100)/

It does not matter what format I use to save the dates (as long as its valid), the result always includes the +xxxx after the unix time stamp.

I can manipulate and parse the json dates manually, but can anyone tell me why I end up with a unix time stamp plus the +xxxx. It means I cannot just parse the date with:

new Date(jsondate)

getting 'Could not establish DB connection' error incosistently

I am getting callback error while performing some sql queries using this plugin in windows phone 8 app, Sometimes it works fine and sometime i do get ' Error in success callback: WebSql743852156 = Error: Could not establish DB connection' error on openDatabase() statement.

crash if restarted quickly

I'm still working on small test case, but in our app if the app is closed and immediately reopened then it crashes almost immediately.
f you wait at least 10 seconds then it works as expected.
The DB is very small (half dozen tables, hardly any data).

If I comment the openDatabase() then this doesn't occur.
Crashes never occur when connected to the Visual Studio debugger.

is there an easy way to capture the crash?

The given key was not present in the dictionary

When installing the plugin via CLI, the database opens, but crashed on Windows Phone when trying to create a table. This was issue #25. I did the workaround metionted there by installing via github reference, which worked for me some months, but now I'm getting "The given key was not present in the dictionary.".

db object replaced as a string

in a variable where you expect a reference to the db object, their is only a reference to a string which is the full path of the database.

I think this was to do with the order of my async operations.

error thrown on:

SqlTransaction.prototype.executeSql [SqlTransaction.js] Line 105 Script

values the error is thrown with:
"Error occured while executing sql: " + me.sql + '. Error: ' + lastError
me.sql = "ROLLBACK TO trx1"
lastError.code = 14
lastError.message = "unable to open database file"

I exposed this bug on my branch MetaMemoryT@da72041

It comes on the second transaction ran.

I am wondering, do you think it could be related to storesafe/cordova-sqlite-storage@049879f ?

My db variable (which used to be a Database object) turns into the string: "C:\Users\Sean\AppData\Local\Packages\com.msopentech.websql.tests_dsh9t8a1qg3mw\LocalState\Todo"

is LocalState where its supposed to be?

Is their any short term workaround I could use?

Not able to Delete Records

Hi , I am new to apache cordova and am trying to do a simple ToDo app as given in the samples. I am able to insert and read the records from the database but the records are not getting deleted. I have used it in a similar way as shown in the sample.

When I use the Ripple Emulator in Google Chrome in Visual Studio 2015 it works as expected but when I deploy to an android device (Nexus 4) it is not working. Just the delete functionality is not working.

The Delete All :
db.transaction(function (tx) {
alert('In Delete All');
tx.executeSql("DELETE FROM todo", null, onSuccess, onError);
});

Please help me resolve this incase I have missed any of the settings or used it wrongly.

Getting error ..\plugins\cordova-plugin-websql\src\windows\SQLite.Proxy\bin\Release\SQLite.Proxy.pri not found

I have an issue taking build from Microsoft Visual studio Community 2015 while it works fine running to a device. Project >Store > Create App Packages returns me a build failed message showing error as \plugins\cordova-plugin-websql\src\windows\SQLite.Proxy\bin\Release\SQLite.Proxy.pri not found .When checked it was observed that the Release folder in the path defined is empty. Is there any possible scenario as to why SQLite.Proxy.pri and SQLite.Proxy.winmd files are not generated to the plugin folder. Please provide some work around for this issue.

No Support for Storing and Retrieving JSON blobs in WP 8

Hi - In an effort to avoid storing and retrieving simple text strings, I implemented some basic code to 'stringify' arrays of JSON objects and store the entire string. When retrieving the JSON object I simply grab the string, parse the response, and deserialize the JSON into objects.

This all works great in Android and Windows 8, but does not work in Windows Phone 8 (the data does not persist when app is closed and restarted). I was pleasantly surprised at how compatible Windows 8 is with the plugin. Any idea why WP8 does not behave the same way?

Open Database not Working

I have made a project of Windows8 Metro app with cordova 3.4.0. This plugin is not working in my project and giving an error of "Unable to create Database".

I have included all the libraries. I don't understand where the problem is. Can you please help me out on this or is there anyone whose facing similar problems.

Help on Windows 8.1 Cordova app

Hi Sergey,

I have to port ios cordova app to windows app.

After creating the cordova projects, I copied the required files and installed the required plugins but not able to run the project successfully.

App is executed but local data base is not created and so no table is created.

It will be the great help if someone can check whats wrong.

Please download the code from following:
http://www.4shared.com/zip/wFR6aPG2ce/windows.html

Thanks & Regards, Gaurang

Plugin should be asynchronous

The WebSQL interface described as in the W3 specification (http://www.w3.org/TR/webdatabase/#asynchronous-database-api) is asynchronous. This plugin however is synchronous. This is unfortunately a major issue for the user experience.

I know its possible because Cordova offers a async API for native calls. The methods should return an IAsyncOperation which can be retrieved from a System.Thread.Task. The JavaScript will then return a promise instead of an instance of T.

wrong reference to proxy file

My app is crashing at start where i open the Data Base i believe.
I'm getting an error "Connection not set" in SqlTransaction.js but i believe is coming from before,
where i also get this warning "The referenced project 'app\plugins\cordova-plugin-websql\src\windows\SQLite.Proxy\SQLite.Proxy.csproj' does not exist. [app\platforms\windows\CordovaApp.Phone.jsproj]"

So i look for /SQLite.Proxy.csproj but i found /SQLiteProxy.cs instead.

So i try to change this reference, but every time i build (VS15), the plugin.xml gets overwritten.

UPDATE: the test for websql work fine, as well as the sample todo code for indexeddb, so i create a blank project and migrate my app to that project and now it works. i really don't know why.

select query returns an unsigned value of negative real present in the table

Issue is if table is created with two columns(one having real and other as text), then if negative value is stored in the first field and in second field value with more than 983 chars are present then, while fetching the data it will return unsigned value of first field(65536-value).

Steps to reproduce the issue :-

tx.executeSql('CREATE TABLE IF NOT EXISTS DEMO (id REAL UNIQUE, data TEXT)');
var k = -1505;
//Length of this val variable must be greater than 983 chars
var val = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";

    tx.executeSql('INSERT INTO DEMO (id, data) VALUES (?, ?)',[7123.0,val]);

    tx.executeSql('UPDATE DEMO SET id=? where id=?',[k,'7123.0']);
    tx.executeSql('SELECT * from DEMO',[],function(tx, result){
                                                         console.log(result.rows.item(0).id);},
                                                         function(){
                                                         console.log('error');     
                                                          });

Result is :: 64031
Expected :: -1505

When i disconnect my from phone from Visual Studio

Hi when i deploy app from Visual studio it works fine. When i disconnect the phone and try to open the app. App goes blank. I investigated it further.. when i remove reference of Sqlite , app works.
Windows phone 8.1

Table created and first record inserted but then disappears

I'm very happy with this plugin, that I can finally see something works with my websql database in windows phone. However, I got this problem.

Here is my open database codes:

`var db = openDatabase("MyTable", "1.0", "mytable", 2000000);
db.transaction(newVehicles, function(tx, err){ console.log("Error processing vehicle: "+ JSON.stringify(err)); });
function newVehicles(tx){
   tx.executeSql("SELECT COUNT(*) FROM VEHICLES", [], function(tx){
	console.log('table found');
   }, function(tx, err){
	console.log('No table found. Going to create table. '+ JSON.stringify(err));
	tx.executeSql('DROP TABLE IF EXISTS VEHICLES', [], function(tx, res){ console.log('table dropped'+ JSON.stringify(res)) }, function(tx, err){ console.log('no vehicles table found: '+ JSON.stringify(err)) });
	tx.executeSql('CREATE TABLE IF NOT EXISTS VEHICLES (id INTEGER PRIMARY KEY, polnum, license)', [], function(tx, resultSet){
		console.log('new app, new VEHICLES table has been made. '+JSON.stringify(resultSet));
	}, function(tx, err){
		console.log('Cannot create table '+ JSON.stringify(err)); 
	});
	
	tx.executeSql("SELECT COUNT(*) FROM VEHICLES", [], function(tx, resultSet){ console.log('vehicle table now existed. '+JSON.stringify(resultSet)); }, function(tx, err){ console.log('vehicle table still not existed. '+JSON.stringify(err)); });
	
	tx.executeSql('INSERT INTO VEHICLES (polnum, license) VALUES (?, ?)', ['123XX', 'XX123'], function(tx, results){ console.log('table created and new record inserted. '+JSON.stringify(results)); }, function(tx, err){ console.log('none inserted: '+ err.message); });
   });
}`

From the console I got this results:

  • No table found. Going to create table. {"code":1,"message":"no such table: VEHICLES"}
  • table dropped{"insertId":0,"rows":[],"rowsAffected":0}
  • new app, new VEHICLES table has been made. {"insertId":0,"rows":[],"rowsAffected":0}
  • vehicle table now existed. {"insertId":0,"rows":[{"COUNT(*)":0}],"rowsAffected":0}
  • table created and new record inserted. {"insertId":1,"rows":[],"rowsAffected":1}
  • Error processing vehicle: {"code":1,"message":"no such table: VEHICLES"}

For the first time, no table found. Then vehicles table created. And I checked one more time, and it says the table is existed. Furthermore, I can insert a record.

However, the db.transaction says, no table found. And if I reopen the app, it says again that no table is found. How come did the table just disappear?

Could someone tell me where my mistake here? Have I made a temp table here?

WP8 - error "unable to delete file"

When i start the app the first time after installation the query that i want to perform (a select) is not performed and the error

"code:0 Unable to delete file"

is provided.

If i close the app and open again it work perfect. Why?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.