-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfetchdatabase.js
36 lines (26 loc) · 893 Bytes
/
fetchdatabase.js
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
//download stuff
const express = require('express');
const app = express();
const mssql = require("mysql");
app.get('/', function (req, res) {
// Config your database credential
const config = {
user: 'linroot',
password: 'eXTDUj0AxkAUPe!7',
server: 'lin-7861-5188-mysql-primary.servers.linodedb.net',
database: 'example'
};
// This should connect to a database
mssql.connect(config, function (err) {
var request = new mssql.Request();
//Find that shit
request.query('select * from example',
function (err, records) {
if (err) console.log(err)
//display data to local browser
res.send(records);
});
});
});
var server = app.listen(5000, function () {
console.log('Server is listening at port 5000...');