2
我想知道我怎麼能在變量保存MySQL查詢結果使用節點JS使用保存在變量MySQL查詢的結果節點JS
我用這個連接到MySQL,並得到查詢
var mysql = require('mysql');
var express = require('express');
var app = express();
app.get('/informations', function (req, res) {
var connection = mysql.createConnection(
{
host : 'localhost',
user : 'root',
password : '',
database : 'dbUsers',
}
);
connection.connect();
var queryString = 'SELECT * FROM hpform';
connection.query(queryString, function(err, rows, fields) {
res.json(rows);
for (var i in rows) {
console.log('NomBase: ', rows[i].NomBase);
console.log('CheminHP: ', rows[i].CheminHP);
console.log('Chemin: ', rows[i].Chemin);
console.log('HPuser: ', rows[i].HPuser);
console.log('pass: ', rows[i].pass);
console.log('path_pub: ', rows[i].path_pub);
}
});
connection.end();
});
module.exports = app;
,我有這結果:
[{"HPId":16,"NomBase":"Base","CheminHP":"C:\\Program Files (x86)\\Hewlett-Packard\\HP Exstream\\HP Exstream 9.5.102","Chemin":"P:\\\\EXSTREAM\\\\BASES\\\\MACSF_DB_EditiqueV9.5.accdb","HPuser":"admin","pass":"admin","path_pub":"D:\\Users\\hbenkhal\\Desktop\\essaipub"},{"HPId":21,"NomBase":"LMG","CheminHP":"C:\\Program Files (x86)\\Hewlett-Packard\\HP Exstream\\HP Exstream 9.5.102","Chemin":"D:\\\\hp_LMG\\\\BaseAccess20160330.accdb","HPuser":"admin","pass":"admin","path_pub":"D:\\Users\\hbenkhal\\Desktop\\essaipub"},{"HPId":22,"NomBase":"Meriem","CheminHP":"C:\\Program Files (x86)\\Hewlett-Packard\\HP Exstream\\HP Exstream 9.5.102","Chemin":"D:\\base_meriem\\Test.accdb","HPuser":"admin","pass":"admin","path_pub":"D:\\Users\\hbenkhal\\Desktop\\essaipub"},{"HPId":24,"NomBase":"bouygues","CheminHP":"C:\\Program Files (x86)\\Hewlett-Packard\\HP Exstream\\HP Exstream 9.5.102","Chemin":"D:\\\\hp_LMG\\\\bouygues\\\\20160425 - PRODUCTION MEP FE_22606 - Ano314002 Libellé remboursement EDP Appro","HPuser":"admin","pass":"admin","path_pub":"D:\\Users\\hbenkhal\\Desktop\\essaipub"},{"HPId":26,"NomBase":"hamza","CheminHP":"C:\\Program Files (x86)\\Hewlett-Packard\\HP Exstream\\HP Exstream 9.5.102","Chemin":"P:\\\\EXSTREAM\\\\BASES\\\\MACSF_DB_EditiqueV9.5.accdb","HPuser":"admin","pass":"admin","path_pub":"D:\\Users\\hbenkhal\\Desktop\\essaipub"}]
現在我想我的結果保存爲使用它們exec命令是這樣的
012的請求child = exec("\"" + req.session.CheminHP + "/Packager.exe\" -APPLICATION=" + req.params.app + " -ACCESSDB=" + req.session.Chemin + " -EXSTREAMUSER=" + req.session.HPuser + " -EXSTREAMPASSWORD=" + req.session.pass + " -PACKAGEFILE=" + req.session.path_pub + "\\" + req.params.app + ".pub", function (error, stdout, stderr)
我可以有一個建議來做到這一點。 謝謝。
好的謝謝,但我怎麼能定義elem? –
對不起,我的錯。我修復了它。 –