Answer the question
In order to leave comments, you need to log in
Node.js + node-sqlite3. How to send a generated request?
I make a query to the database through the node-sqlite3 module.
Code part:
var rowPool = [];
var rowPool2 = [{id:0}];
var rowPool3 = [];
var select='SELECT rowid AS id, title, kod FROM telefon_ron';
var select2='SELECT rowid AS id, title FROM telefon_otdel WHERE ron_id=1';
db.serialize(function(){
db.all(select, function(err, row) {
rowPool=row;
console.log(rowPool); //Выводит содержимое
});
db.all(select2, function(err, row) {
rowPool2=row;
console.log(rowPool2); //Выводит содержимое
console.log(rowPool2[0].id); //Выводит: 4
//select3=`SELECT rowid AS id, title FROM telefon_potdel WHERE otdel_id=${rowPool2[0].id}`;
});
db.all(`SELECT rowid AS id, title FROM telefon_potdel WHERE otdel_id=${rowPool2[0].id}`, function(err, row) {
console.log(rowPool2[0].id); //Выводит: 4
rowPool3=row;
console.log(rowPool3); //Выводит пустой массив: []
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question