forked from LearnCodeToday/TutorialOnNodeJs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmysqlConnectionStringProvider
More file actions
37 lines (21 loc) · 878 Bytes
/
mysqlConnectionStringProvider
File metadata and controls
37 lines (21 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var mysql = require('mysql');
var mysqlConnectionString = require('./mysqlConnectionString.js');
var mysqlConnectionStringProvider = {
getMySqlConnection : function () {
var connection = mysql.createConnection(mysqlConnectionString.mysqlConnectionString.connection.dev);
connection.connect(function (err) {
if (err) { throw err; }
console.log('Connected Successfully');
});
return connection;
},
closeMySqlConnection : function (currentConnection) {
if (currentConnection) {
currentConnection.end(function (err) {
if (err) { throw err; }
console.log('connection closed successfully.')
})
}
}
}
module.exports.mysqlConnectionStringProvider = mysqlConnectionStringProvider;