i have the following problem. I designed my litesql database over 'DB Browser for SQLite' and I'm stuck as soon as a query gets executed. The functions I am exporting are getting imported and used in nativescript-vue.
Webpack also copies the database with *.sqlite ending to the device. The android version I use is 9.
The way I initialize my db is;
var Sqlite = require("nativescript-sqlite");
var db;
export function init() {
if (!Sqlite.exists("test.sqlite")) {
Sqlite.copyDatabase("test.sqlite");
}
new Sqlite("test.sqlite", function(err, dbConnection) {
if (err) {
console.log(err);
return;
}
db = dbConnection;
console.log("connection successful")
});
}
After running the function console shows 'connection successful'. The database is placed in the root of the app folder. That way it should pull the database? Besides I got another question. How could I hide the database in the production?
So the way I execute the query is:
export function xxxx(**parameter**) {
db.execSQL(
"select random_id from random_table where some_id = ?",
**parameter**,
function(err, result) {
console.log("result 1: " + result + " err: " + err);
}
);
}
The output is:
JS: 'result 1: null err: null'
I'm not even sure if it opens the database in the right way?
db.getfor select statements. Besides what you mean by hiding database on production? If you like DB not to be part of source code then you should probably download it on the fly Or use paid version of the plugin which supports encryptions.