Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 2019 14:34
    willmorgan commented on 889cbf1
  • Jan 31 2019 13:15
    gsamal commented on 889cbf1
  • Jan 31 2019 13:10
    dhensby closed #797
  • Jan 31 2019 13:10
    dhensby commented #797
  • Jan 31 2019 13:07
    dhensby closed #795
  • Jan 31 2019 13:07
    dhensby commented #795
  • Jan 31 2019 12:58
    gsamal commented #789
  • Jan 31 2019 11:50
    cesco69 opened #797
  • Jan 31 2019 10:22

    dhensby on master

    Update changelog for v5 Merge pull request #796 from dh… (compare)

  • Jan 31 2019 10:22
    dhensby closed #796
  • Jan 31 2019 09:53
    dhensby commented #789
  • Jan 31 2019 09:52
    dhensby commented #778
  • Jan 31 2019 09:51
    dhensby review_requested #796
  • Jan 31 2019 09:51
    dhensby opened #796
  • Jan 31 2019 06:45
    suckerp commented #795
  • Jan 31 2019 02:58
    liumorgan starred tediousjs/node-mssql
  • Jan 31 2019 02:15
    zhoukk starred tediousjs/node-mssql
  • Jan 30 2019 22:22
    vjpr edited #795
  • Jan 30 2019 22:22
    vjpr edited #795
  • Jan 30 2019 22:22
    vjpr opened #795
Chris Rutherford
@cjrutherford
Hey all, how should I form my query if there is a table I would like to join that should be an array on the total object?
Dai Nguyendo
@dainguyendo

Greetings! Does node-mssql support auto-incrementing id's during bulk upload? I have attempted multiple column configurations such as , table.columns.add('id', sql.Int, { primary: true identity: true }); - however I still require to input values for these columns which is not the desired effect.

To expand, TSQL's CREATE TABLE mytable ([id] INT IDENTITY(1,1) NOT NULL) will auto increment on each insert of a new row. Thoughts/suggestions?

David Gasperoni
@mcdado
You could create the raw statement, no?
Dai Nguyendo
@dainguyendo
@mcdado , apologies - could you explain further?
For context, I am creating tables on-the-fly based on the data we receive, however I have since learned I need to have primary keys to relate the data to another table. I am utilizing bulk uploads as the data to be inserted may be quite large - following the documentation, I need to first create the table (which continuously changes in number of columns however requires an ID), then implement table.rows.add() with the values for each column in order.
David Gasperoni
@mcdado
I see, then creating a raw statement might be problematic
What I meant is using a prepared statement and write a tsql query in it
Dai Nguyendo
@dainguyendo
Yeah, it would be great to hear if anyone else ever had to approach a problem such as this. The documentation gives clues such as those additional object properties to the method however nothing in plain text to auto-incrementing and PKs. Thanks for the assistance @mcdado !
PmoriartyPhoenix
@PmoriartyPhoenix
Was just wondering. In both the tedious driver and mssqlserverv8 there is no mention of 2016 allways on ag cluster support. Are they supported. (I know its your driver, not the wrapper question. Sorry)
davemeech
@davemeech

I'm getting pretty desperate here. I am looking for examples on how to properly perform transactions with looped inserts using mssql and I'm running into problems. patriksimek/node-mssql#550

If anyone can help I'd be eternally grateful.

trivedimehulk
@trivedimehulk

Guys.. I am facing a small issue here.
When I run to fetch big data from my table the call is blocking all other static content request to node server.

Have anybody faced this problem?
Ping me if need more details.

David Gasperoni
@mcdado
Can you paste the code where you’re fetching?
trivedimehulk
@trivedimehulk
yeah sure.
hold on

const sqlInstance = require('mssql');
const express = require('express');
const app = express();
app.get('/', (req, res) => {

if (req.query.p == 'sql') {

    var setUp = {
        server: 'myservername',
        database: 'Products',
        user: 'Products',
        password: 'Products',
        port: 1433,
        options: {
            encrypt: true
        }
    };

    sqlInstance.connect(setUp).then(function (connection) {
        var _sqlRequest = new sqlInstance.Request(connection)
            .query("[GetAllProducts]")
            .then(function (dbData) {
                if (dbData == null || dbData.length === 0)
                    res.send('No data boss!');
                res.send('Loaded big data');
                sqlInstance.close();
            })
            .catch(function (error) {
                console.dir(error);
            });
    })

} else {
    res.send('Responded to static request!!!');
}

})

var printLog = function(log){ console.log(log);};

app.listen(3000, () => console.log('Example app listening on port 3000!'))


David Gasperoni
@mcdado
You open a connection to db at every request? I would make a connection promise and reuse that at each request. I don’t think it will solve your issue but it might be faster
Connection would occur at app startup
trivedimehulk
@trivedimehulk
David
thia isnmy pic
David this is my poc code. I’ll take care of it.
David Gasperoni
@mcdado
Alright, I was just wondering. Because that definitely adds some delay. I’m not sure about blocking though, as you seem to always do the right thing and return promises/callbacks
Zheyi Zhu
@Voxis

hi im trying to dynamically add tvp data into tvp table. I need some help here…
I have already new the table and added the columns no problem there

let columns = _.map(tvpData.columns, 'name');
tvpData.data.forEach((item) => {
        tvp.rows.add.apply(null, columns.map((c) => item[c]));
});

but it seems stuck in this foreach. any help would be appreciated

Tim Oien
@toien44
Looking into tools to test against a DB and someone pointed me here. I need to test against SQL Management studio client I guess it's a GUI interface but should still be able to throw commands at it. Would this library work to verify that a job is set correctly and ran?
Tim Oien
@toien44
What tools do people use for using this on a mac? I need a GUI interface too to verify my tests/ steps.
Sean Kelly
@seank-com
I used to use MySQL Workbench. Don't know if it is compatible with MSSQL. Failing that you can always install Windows on a VirtualBox VM
Wellington Rodriguez
@wrod7
@toien44 SQL Operations Studio
dmanhaus
@dmanhaus
If you’re looking to issue SQL commands against a SQL DB on a Mac, I recommend using VS Code. It works well, includes intellisense and source control. Plus it’s good for just about any other language you need to develop in.
Tim Oien
@toien44
ok thanks all
dmanhaus
@dmanhaus
...just be sure to add the MSSQL extension after you install it.
Tim Oien
@toien44
I'm not looking for an editor as I have one I need a way to view the tables on a mac. I'd prefer to not use a VM
Sean Kelly
@seank-com
VSCode will display a table as a result of your SQL query. It's really pretty slick.
Tim Oien
@toien44
oh nice thanks
David Gasperoni
@mcdado
Sql operations Studio by Microsoft
It’s in alpha I think
It’s an electron-based app that’s multi-platform
Tim Oien
@toien44
I'm trying to set up a DB connection would host be the name of the database or a URL?
var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'me',
  password : 'secret',
  database : 'my_db'
});

connection.connect((err) => {
    if (err) {
        console.error(`error connecting: ${err.stack}`);

        return;
    }

    console.log(`connected as id ${connection.threadId}`);
});

connection.end();
Tim Oien
@toien44
I got the HOST figured out however, I can't get the console log to print out
Tim Oien
@toien44
This is what I'm getting when I print out connection. I've changed host to my DB host name
Connection {
  domain: null,
  _events: {},
  _eventsCount: 0,
  _maxListeners: undefined,
  config:
   ConnectionConfig {
     host: '...',
     port: 3306,
     localAddress: undefined,
     socketPath: undefined,
     user: '...',
     password: '...',
     database: '...',
     connectTimeout: 10000,
     insecureAuth: false,
     supportBigNumbers: false,
     bigNumberStrings: false,
     dateStrings: false,
     debug: undefined,
     trace: true,
     stringifyObjects: false,
     timezone: 'local',
     flags: '',
     queryFormat: undefined,
     pool: undefined,
     ssl: false,
     multipleStatements: false,
     typeCast: true,
     maxPacketSize: 0,
     charsetNumber: 33,
     clientFlags: 455631 },
  _socket: undefined,
  _protocol:
   Protocol {
     domain: null,
     _events: {},
     _eventsCount: 0,
     _maxListeners: undefined,
     readable: true,
     writable: true,
     _config:
      ConnectionConfig {
        host: '...',
        port: 3306,
        localAddress: undefined,
        socketPath: undefined,
        user: '...',
        password: '...',
        database: '...',
        connectTimeout: 10000,
        insecureAuth: false,
        supportBigNumbers: false,
        bigNumberStrings: false,
        dateStrings: false,
        debug: undefined,
        trace: true,
        stringifyObjects: false,
        timezone: 'local',
        flags: '',
        queryFormat: undefined,
        pool: undefined,
        ssl: false,
        multipleStatements: false,
        typeCast: true,
        maxPacketSize: 0,
        charsetNumber: 33,
        clientFlags: 455631 },
     _connection: [Circular],
     _callback: null,
     _fatalError: null,
     _quitSequence: null,
     _handshake: false,
     _handshaked: false,
     _ended: false,
     _destroyed: false,
     _queue: [],
     _handshakeInitializationPacket: null,
     _parser:
      Parser {
        _supportBigNumbers: false,
        _buffer: <Buffer >,
        _nextBuffers: [Object],
        _longPacketBuffers: [Object],
        _offset: 0,
        _packetEnd: null,
        _packetHeader: null,
        _packetOffset: null,
        _onError: [Function: bound handleParserError],
        _onPacket: [Function: bound ],
        _nextPacketNumber: 0,
        _encoding: 'utf-8',
        _paused: false } },
  _connectCalled: false,
  state: 'disconnected',
  threadId: null }
Oliver Jourmel
@ojourmel

Hi folks,

Does anyone have any experience with using SESSION_CONTEXT on SqlServer 2016/2017?

I'm running into some issues, and I'm hoping someone can help me confirm it's not just me!

// Assuming some connection pool: cp
const sql = require('mssq');
const request = new sql.Request(cp).query("SELECT SESSION_CONTEXT(N'user_var') AS [sc]");
request
    .then(r => console.log(r))
    .catch(e => console.log(e));

I'm running into an internal error, with an unknown sqlstate. I'm hoping I'm missing something here. Any ideas?

Cheers!

Oliver Jourmel
@ojourmel

Turns out this error is caused by invalid types... SESSION_CONTEXT returns sql_variant which is not supported by node-mssql.

Casting / converting the result to nvarchar seems to fix the error:

SELECT CONVERT(NVARCHAR(max), SESSION_CONTEXT(N'key')) AS [sc]

Cheers!

alexlpze
@alexlpze_twitter
Hi, I'm new using mssql module and I'm trying to implement a repository where each method open a execute some queries and then close the pool but when I stress the method I'm receiving an error about global connection that already exists. does anyone have a connection pool using example?
alexlpze
@alexlpze_twitter
here is a simple example (I avoid try catch and another code to short the example)
const sql = require('mssql');

async  getCatalogbyId({dbconfig, catId}){
   let pool = await sql.connect(dbconfig);
   let catalog = await pool.request().query(`SELECT * FROM oper.CATALOG WHERE  CATID = ${catId}`);
   return catalog.recordset;
}
Wellington Rodriguez
@wrod7
has anyone ever ran into TimeoutError: ResourceRequest timed out? how can i fix this without having to restart the node app?
camarrone
@camarrone
hello everyone
Labs
@labs20
Hi. I'm running into ResourceRequest time out too without any plausible clue. Its random, the server is not overloaded (its a test environment). Any ideas or directions anyone? Thanks!
Wellington Rodriguez
@wrod7
i switched all my methods to prepared statements and i don’t get the error anymore. but still would like to have it reconnect when the error is thrown
Labs
@labs20
mmm... thanks for the info. I'll check on that.
But it still sounds a little off, doesn't it?
Jason Luboff
@JLuboff
I am using SQL Express for dev, and was experiencing timeouts (no real rhyme or reason). I was using a named instance. I found that if I went into SQL Server Configuration tool, Protocols section and then in the TCP/IP settings under IP Addresses changed TCP Dynamic Ports to blank and TCP Port to 1433, after restarting the service, no longer have time outs. Don't recall if this is the same type of timeouts you both are refering to...but worth looking into..
So now in my config instead of using host: 'localhost\\SQLEXPRESS' I'm using host: 'localhost'
Labs
@labs20
Thanks. Will check on that too. Right now I've upped my pool.max to 10000 and running some tests.