Automation Techs For Productivity And Fun

Connecting To Microsoft SQL Server From Node.js Using Windows Authentication



I usually use Knex.js to connect to databases from Node.js programs.

https://knexjs.org/

According to the official document above, Knex.js is available for connecting to MSSQL, but it failed when I tried to connect using Windows Authentication.

It seems the package "node-mssql" which Knex.js is using, has two drivers: "Tedious" and "msnodesqlv8", and the default driver Tedious does not work with Windows Authentication.

https://www.npmjs.com/package/mssql

I couldn't find out how to change the driver to use from Knex.js, so I gave up using Knex.js and decided to use "msnodesqlv8" directly from my program.

https://www.npmjs.com/package/msnodesqlv8

Example

Here I found a document for msnodesqlv8.

https://github.com/TimelordUK/node-sqlserver-v8/wiki

This is a simple example program to connect with MSSQL and fetch data from a table using Promise.






Share:

Search This Blog

Labels

Generate Data For Testing With PostgreSQL

When developing a software using PostgreSQL database as storage, the function "generated_series" is very useful to create data ...

Powered by Blogger.

Labels

Recent Posts