Answer the question
In order to leave comments, you need to log in
NODE .JS connects to SQL (tedious driver) in 2 seconds! What to do?
Approximately here:
connects 3 seconds though all requests are fulfilled very quickly!
What to do?
INDEX.JS:
'use strict';
var port = process.env.PORT || 8000;
var http = require('http');
var express = require('express');
var app = express();
var server = http.createServer(app);
var bodyParser = require('body-parser');
var path = require('path');
var crypto = require('crypto');
var reduce = require('reduce-component');
var Connection = require('tedious').Connection;
console.log('start');
app.use(bodyParser.json());
app.listen(port, function () {
console.log('Listening on port ', port);
});
var config = {
userName: '12345',
password: '12345*',
server: 'site.com',
options: {encrypt: true, database: 'database'}
};
var Request = require('tedious').Request;
var TYPES = require('tedious').TYPES;
var connection = new Connection(config);
connection.on('connect', function(err){
if(err){
console.log(err);
next();
}else{
var request = new Request("SELECT * FROM dbo.Tabe WHERE Id = '1' ", function(err, rowCount, rows) {
});
request.on("row", function(columns) {
console.log(columns[0].value);
})
connection.execSql(request);
}
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question