Hi,
I'm working on an ionic app..
I'm currently having trouble with the iOS version.
When I open my dataBase with this command :
sqlitePlugin.openDatabase({name : 'XXXXXXDB', location:'default', iosDatabaseLocation:'default'})
I have this in my logs :
2016-05-20 18:14:47.225 XXXXXX[6944:187465] OPEN database: _pouch_XXXXXXDB 2016-05-20 18:14:47.225 XXXXXX[6944:187465] new transaction is waiting for open operation 2016-05-20 18:14:47.227 XXXXXX[6944:187495] Good news: SQLite is thread safe! 2016-05-20 18:14:47.230 XXXXXX[6944:187465] DB opened: _pouch_XXXXXXDB
This is telling me that the database was opened, but I have no return from the promise. This makes my app blocked, even my spinner is not moving.
To reproduce this issue, I open and close my app until I get it.
I know that is a pretty awful way, but some people who use it normally have the same problem.
Everything is great on Android.
please try this
if(ionic.Platform.isIOS())
{
console.log('database is iso');
var db = $cordovaSQLite.openDB({name: 'aljomaa.db', iosDatabaseLocation: 'Library'}); //ios device
}
else
{
console.log('database is android');
db = $cordovaSQLite.openDB({name:'aljomaa.db',location:'default'}); // android device
}
}else{
console.log('start database from browser');
db = window.openDatabase("aljomaa2.db", '1', 'my', 1024 * 1024 * 100); // browser
}
in ios use iosDatabaseLocation option instead of location option
Hello,
Thanks for your answer. I think there is some troubles when you set location and iosDatabaseLocation in the same options. I did this in order to not have to test the platform.
After I separated the location and iosDatabaseLocation, it seems to be great.
Yes. Using both location and iosDatabaseLocation is _not_ supported and should be rejected. I will update the CoffeeScript/JavaScript and the documentation when I get a chance.
_P.S. Thanks guys for reporting and analyzing the issue._
Hi,
First to say thanks for the help...
I have the same problem with iOS, I try to do it:
if(window.cordova && $cordovaSQLite){
localDB = $cordovaSQLite.openDB({name:'MyDB.db', iosDatabaseLocation:'Library'});
}else{
localDB = window.openDatabase("MyDB.db", "1.0", "Ready DB", -1);
var query = 'CREATE TABLE IF NOT EXISTS profile(id integer primary key, name text, cell text, email text, comercialStatus integer)';
$cordovaSQLite.execute(localDB, query).then(function(){
alert('1 execute');
var query = 'CREATE TABLE IF NOT EXISTS actionPlan(id integer primary key, isActive integer, name text, phone text, email text)';
$cordovaSQLite.execute(localDB, query).then(function(){
alert('2 execute');
Profile.get().then(function(data){
alert('Get Profile')
$ionicLoading.hide();
if(!data || data.name === undefined){
$state.go('welcome');
} else if (!data.name){
$state.go('profile');
}
}, function(e){alert('Error Profile')});
}, function(e){alert('Error 2')});
}, function(e){
alert('Error 1');
});
but when it try to generate the database it doesn't work. it not execute the first execute.
If I try to debug with safari it's the same, but If I refresh it works correctly!!!
I'm working with iOS 9.3 and 9.3.2
@neogero please be sure to wait for the deviceready event. This is necessary for all Cordova plugins.
That wasn't really a good answer. Even if the results are better, It's not concluant.
I'm still waiting for almost 5 seconds after the deviceready event to be sure to not freeze my app.
if someone can help me out, I will be grateful.
Thanks @brodybits it solved the issue. My problem was becouse i need it in the app's controller (ionic app). I controlled the ready status previously and it's running correctly
i am solved it on ios with
var db = window.sqlitePlugin.openDatabase({name: 'mydb.db', location: 'default'});
Hi,
I m stuck with same issue as mentioned above, since from week,anyone please help me
I’m working on an ionic1 app…
I’m currently having trouble with the iOS version.
and iam using cordova sqlite plugin,and here db is getting opened but cordovasqlite.execute function(), not working instead iam getting error code:5,message:"no such table:table-name"
for opening database iam using,
if(ionic.Platform.isIOS())
{
console.log(‘database is iso’);
var db = $cordovaSQLite.openDB({name: ‘olarcniapp.db’, iosDatabaseLocation: ‘Library’}); //ios device
}
else
{
console.log('database is android');
var db = $cordovaSQLite.openDB({name:'olarcniapp.db',location:'default'}); // android device
}

I m stuck with same issue as mentioned above
[...]
Please raise that kind of question in https://github.com/litehelpers/Cordova-sqlite-help/issues, not in a closed issue. Please double-check that you highlight your code like this to ensure readability:
```js
// your code here
```
It looks to me like your database was opened but your table was never created.
Most helpful comment
please try this
in ios use
iosDatabaseLocationoption instead oflocationoption