DisyInformationssysteme / Cordova-spatialite-storage

A Cordova/PhoneGap plugin to open and use sqlite databases on Android/iOS/Windows Universal(8.1)/Amazon Fire-OS/WP(7/8) with HTML5/Web SQL API
Other
24 stars 17 forks source link

Usage in Cordova #4

Closed stihl-sicher closed 7 years ago

stihl-sicher commented 7 years ago

Hi,

up to now, I am using litehelpers/Cordova-sqlite-storage in my project but I would like to take advantage of the spatial functionality. I was very glad to find a "spatial fork" of the plugin I am using and tried just replacing the sqlite plugin by the spatialite plugin.

Unfortunately this did not the trick :( When running "_db.executeSQL(..)" there is no reaction at all: Neither a positive response nor an error thrown. using the transaction function I get the error "Invalid database handle".
_db is received as result of window.sqlitePlugin.openDatabase({name: "tgmapper2.db", location: 1, androidDatabaseImplementation: 2}); Might be, there is some very small error in thinking? Could anyone help me?

Best regards and thanks in advance stihl-sicher

stihl-sicher commented 7 years ago

May be, I was just blind ;) Just saw "Issue #4"... ahh, there must be at least three issues before... Took a look at them... I will give the solution mentioned in #2 a try :)

stihl-sicher commented 7 years ago

okay, using an existing empty database does the trick.

Just let me note my experience which might help some others... 1) I tried opening the database placed in the www directory. This did not change any behaviour. So I did 2) Copy the database file to the data directory (I selected externalApplicationStorageDirectory for my try) and tried to use the copied version. This works. So, according to the File-API documentation I suppose I missed write permission in the applications base directory...

Cultrarius commented 7 years ago

@stihl-sicher Thank you for taking the time to post your solution, very nice of you! 👍

Alma9170 commented 4 years ago

Hi,

up to now, I am using litehelpers/Cordova-sqlite-storage in my project but I would like to take advantage of the spatial functionality. I was very glad to find a "spatial fork" of the plugin I am using and tried just replacing the sqlite plugin by the spatialite plugin.

Unfortunately this did not the trick :( When running "_db.executeSQL(..)" there is no reaction at all: Neither a positive response nor an error thrown. using the transaction function I get the error "Invalid database handle". _db is received as result of window.sqlitePlugin.openDatabase({name: "tgmapper2.db", location: 1, androidDatabaseImplementation: 2}); Might be, there is some very small error in thinking? Could anyone help me?

Best regards and thanks in advance stihl-sicher

Hello, I am using cordova-spatialite-storage version 2.0.0, and the way I use the database is like this: try { var query = 'SELECT Geometry From '; var args = []; var querySuccess = function (results) { alert(results) } var queryError = function (error) { alert(error.toString()) } var spatialiteURI = "file:///storage/emulated/0/Documents/DB.sqlite"; var db = window.sqlitePlugin.openDatabase({ name: spatialiteURI }); db.transaction(function (tx) { tx.executeSql(query, args, querySuccess, queryError); }); } catch (ex) { alert(ex.message) } But this code is not working and the plugin can't find my database file(no reaction at all). Is my way of defining database name option wrong ?Or is there another way to do this? It is so critical for me to process spatial data in my app. So any help make this plugin work is so appreciated. Thanks in advance.