var pool = mysql.createPool({
host: "хост",
user: "пользователь",
password: "пароль",
database: "датабаза",
port: 3306,
});
var connection = pool.getConnection(function (err, con) {
if (err) {
console.log("Ошибка датабазы: " + err);
throw err;
}
else {
connection = con;
console.log("Датабаза подключена");
}
});
connection.query('SELECT * FROM `fac`', (result) => {
console.log(result)
})
var pool = mysql.createPool({
host: "хост",
user: "пользователь",
password: "пароль",
database: "датабаза",
port: 3306,
});
pool.getConnection(function (err, connection) {
if (err) {
console.log("Ошибка датабазы: " + err);
throw err;
}
else {
console.log("Датабаза подключена");
connection.query('SELECT * FROM `fac`', function (err, result) {
if (err) {
console.log("Ошибка выполнения запроса: " + err);
throw err;
}
else {
console.log(result);
// do something with the result
}
connection.release(); // always release the connection after you're done with it
});
}
});