mykevin81 /
Personal-Website
| 1 | var mysql = require('mysql'); |
||
| 2 | |||
| 3 | var connection = mysql.createPool({ |
||
| 4 | host: '76.14.31.246', |
||
| 5 | user: 'api', |
||
| 6 | password: 'webaccess1992', |
||
| 7 | port: '3306', |
||
| 8 | database: 'personal_website' |
||
| 9 | }); |
||
| 10 | |||
| 11 | function getProjects(tableName, callback) { |
||
| 12 | |||
| 13 | connection.getConnection(function(err, connection) { |
||
| 14 | if(err) { |
||
| 15 | console.log(err); |
||
|
0 ignored issues
–
show
Debugging Code
introduced
by
Loading history...
|
|||
| 16 | } |
||
| 17 | else { |
||
| 18 | console.log(tableName); |
||
| 19 | var query = 'SELECT * FROM ' + tableName; |
||
| 20 | connection.query(query, null, function(error, result) { |
||
| 21 | if(error) { |
||
| 22 | console.log(error); |
||
|
0 ignored issues
–
show
|
|||
| 23 | } |
||
| 24 | else { |
||
| 25 | callback(error, result); |
||
| 26 | } |
||
| 27 | }); |
||
| 28 | } |
||
| 29 | connection.release(); |
||
| 30 | }); |
||
| 31 | } |
||
| 32 | |||
| 33 | exports.getProjects = getProjects; |
||
| 34 |