NodeJs Express index.js > Mysql 연결
잘 됩니다! 굿
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
/* * GET home page. */ var mysql = require('mysql'); var conn = mysql.createConnection({ host: '192.168.0.1', port: 3306, database: 'database name', user: 'user id', password: 'password', }); exports.index = function(req, res){ conn.query('select * from Test', function (err, rows, fields) { if (err) throw err; console.log(rows); res.render('index', { title: 'select * from Test -> rows.length : ' + rows.length }); }); }; |
0개의 댓글