hi!
I should read from a database (I used xaamp with a mysql database). I put this code in Function (node), but I'm having problems with 'require'. I followed the guide to add external modules, but I can't solve it. Could anyone show some examples of database reading?
FUNCTION:
var mysql = require('mysql');
var connection = mysql.createConnection( { host : 'localhost',
user : 'nome_utente',
password : 'password_utente',
database : 'nome_db'
} );
connection.connect();
var queryString = 'SELECT cmp FROM tbl ORDER By id DESC';
connection.query(queryString, function(err, rows, fields) {
if (err) throw err;
for (var i in rows) {
console.log('Valori: ', rows[i].cmp);
}
});
connection.end();