Sqlite: Unable to open database

Asked

Viewed 345 times

1

Application using Ionic/Cordova (Sqlite).

I’m using the $cordovaSQLite plugin inside the app. When I save, modify something in the project, the simulation in brownser (Googlechrome) is extremely slow to load and when it loads the following errors appear:

Unable to open database, failed to start transaction (5 database is locked)

Uncaught Domexception: Failed to execute 'openDatabase' on 'Window': Unable to open database, failed to start transaction (5 database is locked)

This is how I create and open my bank:

db = window.openDatabase("FidelisApp", "1.0", "DB Teste", "5000");
$cordovaSQLite.execute(db, "CREATE TABLE IF NOT EXISTS Users (userID text primary key, correio text, name text, phone num, senha num, cep num, endereco text, bairro text, cidade text, estado text, pais text)");

One of the ways I use my Sqlite bank:

var query = "INSERT INTO users (userID, correio, name, phone, senha, cep, endereco, bairro, cidade, estado, pais) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
            $cordovaSQLite.execute(db, query, [userData.uid, user.correio, user.name, user.phone, user.senha, '', '', '', '', '', '']).then(function(result) {
                console.log("INSERT ID -> " + result.insertId);
            }, function(error) {
                console.error(error);
            });

First time I’m using Sqlite, help me!

  • ps: not even close the browser I can! o. The"

  • has more details of the log when this error is issued? try to differentiate also when it is in context webbrowser and mobile. for example: if (Ionic.Platform.isIOS() || Ionic.Platform.isAndroid()) { database = $cordovaSQLite.openDB('DB Test', 'default'); } Else { database = window.openDatabase('DB Test', '1.0', 'Cordova', 200000); } -- also try to identify whether the error only occurs in browser transactions or when testing in the application as well.

  • Can you put the controller.js and/or service.js you’re using into the save stream ? Preferably the whole stream, you click on a button to save for example until the execution of this execute method. Maybe you have the code on github and want to show it too.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.