I am trying to use the SQLite cordova plugin on my Ionic 2 app.
My code looks like this :
this.platform.ready().then(() => {
let options = { name : "my_db" };
this.storage = new Storage(SqlStorage, options);
this.storage.query("CREATE TABLE IF NOT EXISTS categories (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(50))", []).then((data) => {
console.log("New table : " + JSON.stringify(data));
}, (error) => {
console.log(error);
});
});
And Iām getting an error I donāt really understand (at least in this case) : number of '?'s in statement string does not match argument count.
I installed cordova-sqlite-plugin, even though Iām pretty sure itās only used on a real phone/emulator, so I donāt think this should be causing any problem.
I copied/pasted your code in mine and it is working.
I am not an expert, but do you have other code that āinsertā or āupdateā or ādeleteā things from ācategoriesā tables? I think it is in that part of the code that you have an issue, no?
No, I donāt have any other code like āinsertā at the moment, because the table I tried to create is never created, so Iām basically stuck at this point. As mentioned, I get the error : number of '?'s in statement string does not match argument count when I try to create the table. (The (error) callback is called).
Iām using Chrome, and when I inspect āWebSQLā under the āResourcesā tab, I only have a table ākvā created (which I assume is used to store as data ākey-valueā, and not using the query method. No sign of my ācategoriesā table.