이승규

node, mysql connection test

module.exporst = {
host : 'localhost',
user : 'root',
password : 'Dltgld55%%',
port : 3306,
database : 'my_db'
};
\ No newline at end of file
const mysql = require('mysql');
const option = require('./db_option');
const connection = mysql.createConnection(option);
connection.connect();
connection.query('SELECT * FROM Persons', (err, rows, fields) => {
if (!err) {
console.log('The solution is :', rows);
}
else {
console.error('error: ', err);
}
});
connection.end();
\ No newline at end of file
This diff is collapsed. Click to expand it.
{
"name": "express-mysql",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "4.17.0",
"mysql": "2.17.1"
}
}
This diff could not be displayed because it is too large.
......@@ -17,6 +17,7 @@
"http-errors": "~1.6.2",
"morgan": "~1.9.0",
"mysql": "^2.16.0",
"pm2": "^3.5.0",
"request": "^2.88.0",
"socket.io": "^2.1.1"
}
......