이승규

node, mysql connection test

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