I’m trying to follow whatever examples I can find about using SQLite…most are for older versions of ionic. So I’m trying to open the database, but getting an error (in my browser, via ionic serve). So I have a couple questions:
Here’s my code:
let db = new SQLite();
db.openDatabase({
name: "myDB.db",
location: "default"
}).then(() => {
db.executeSql("CREATE TABLE IF NOT EXISTS...<snipped>..)", {}).then((data) => {
console.log("TABLE CREATED: ", data);
}, (error) => {
console.error("Unable to execute sql" + JSON.stringify (error);
})
}, (error) => {
console.error("Unable to open database"+ JSON.stringify(error)); <<<<<<<<<< I get this error
});
});
}
-
my DB doesn’t exist… how do I use the CREATE_IF_NEEDED parameter? I can’t find any examples of passing that into the plugin. Seems that it should be part of the openDatabase (name, location…)
-
is my problem that I cannot use this code in the browser and I should try the emulator? My emulator won’t start, so I’m kinda at a loss there (it pops up and I see the ANDROID pulsing letters, but the app never runs. )
Thanks,
Bret