You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
|
|
|
|
|
|
|
const mysql = require('mysql2');
|
|
|
|
|
|
const connection = mysql.createConnection({
|
|
|
|
|
|
host : 'localhost',
|
|
|
|
|
|
user : 'root',
|
|
|
|
|
|
password : 'Skyinno251,',
|
|
|
|
|
|
database : 'appserver'
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
connection.connect((err) => {
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
console.error('连接失败: ' + err.stack);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
console.log('连接成功,线程ID: ' + connection.threadId);
|
|
|
|
|
|
//
|
|
|
|
|
|
var sql = 'SELECT * FROM temperature where id < 50';
|
|
|
|
|
|
//查
|
|
|
|
|
|
connection.query(sql,function (err, result) {
|
|
|
|
|
|
if(err){
|
|
|
|
|
|
console.log('[SELECT ERROR] - ',err.message);
|
|
|
|
|
|
connection.end();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
console.log('--------------------------SELECT----------------------------');
|
|
|
|
|
|
console.log(result);
|
|
|
|
|
|
console.log('------------------------------------------------------------\n\n');
|
|
|
|
|
|
connection.end();
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|