Skip to content

Releases: TimelordUK/node-sqlserver-v8

Release v5.1.1

13 Jul 13:42

Choose a tag to compare

Full Changelog: v4.5.0...v5.1.1

This release is a huge change and must be tested carefully before production release.

  1. we have moved from nan to napi node api to buld the cpp
  2. added extensive logging that can be switched on to see exactly what driver is doing
  3. now building and testing with git actions.
  4. we only support ubuntu glib 2204 or later, if you run on earlier linux you have to build the driver yourself
  5. as much as possible drop in replacement to previous version < 5 of the driver.
  6. we no longer support anything less than node 20, electron 30
  7. we no longer support win32
  8. we build for windows, linux and mac os latest versions
  9. alpine linux will be a best effort but this is no longer considered in scope for supported builds.

can use different pool grown strategy - exponential, gradual

 it('gradual growth strategy - creates fixed increment of connections', function handler (done) {
      const size = 10
      const increment = 3
      const options = {
        connectionString: env.connectionString,
        ceiling: size,
        scalingStrategy: 'gradual',
        scalingIncrement: increment,
        scalingDelay: 0
      }
      const pool = new env.sql.Pool(options)

      const checkins = []
      const checkouts = []
      let queryCount = 0

      pool.on('error', e => {
        assert.ifError(e)
      })

      pool.on('status', s => {
        switch (s.op) {
          case 'checkout':
            checkouts.push(s)
            break
          case 'checkin':
            checkins.push(s)
            break
        }
      })

      pool.open(() => {
        // Submit enough queries to trigger growth
        const queries = 7 // More than initial pool but less than ceiling

        for (let i = 0; i < queries; i++) {
          const q = pool.query('select @@SPID as spid')
          q.on('done', () => {
            queryCount++
            if (queryCount === queries) {
              // Check that we didn't immediately grow to ceiling
              expect(checkouts.length).to.be.lessThan(size)
              // Should have grown by increment amount multiple times
              expect(checkouts.length).to.be.greaterThan(1)
              // The growth should be in increments
              const totalConnections = Math.max(...checkouts.map(c => c.busy + c.idle))
              expect(totalConnections).to.be.lessThan(size) // Not aggressive growth
              pool.close(done)
            }
          })
        }
      })
    })

detailed logging output

'use strict'

// Handle SIGPIPE gracefully when output is piped
process.on('SIGPIPE', () => {
  process.exit(0)
})

const sql = require('../../lib/sql')

// Example 1: Enable trace logging for debugging
// This will show all JavaScript and C++ debug messages
sql.logger.setLogLevel(sql.LogLevel.TRACE)
sql.logger.setConsoleLogging(true)

// Example 2: Enable logging to a file
// sql.logger.setLogFile('/var/log/myapp/sql-trace.log')

// Example 3: Use pre-configured settings
// sql.logger.configureForDevelopment()  // TRACE level, console enabled
// sql.logger.configureForProduction('/var/log/myapp')  // ERROR level, file only
// sql.logger.configureForTesting()  // SILENT level

// Example 4: Disable all logging (default for production)
// sql.logger.setLogLevel(sql.LogLevel.SILENT)

// Now all SQL operations will use the configured logging

const { TestEnv } = require('../../test/env/test-env')
const env = new TestEnv()
const connectionString = env.connectionString

sql.open(connectionString, (err, conn) => {
  if (err) {
    console.error('Connection failed:', err)
    return
  }

  conn.query('SELECT 1 as test', (err, results) => {
    if (err) {
      console.error('Query failed:', err)
    } else {
      console.log('Query succeeded:', results)
    }
    conn.close()
  })
})                                                                                             
image

This adds some much needed support for doing transactions from a pool with a few helper utilities.
Notable new API methods:

pool.beginTransaction(function (err, description) { /* description.connection.query() */ })

Pulls a connection information out of the pool and gives it to the caller. This connection becomes busy for the duration until either of next two functions are called:

pool.commitTransaction(description, function(err) { /* err logging */ })

Calls IF (@@TRANCOUNT > 0) COMMIT TRANSACTION on the connection in the description and releases it back into the pool allowing it to be used by others.

pool.rollbackTransaction(description, function(err) { /* err logging */ })

Calls IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION on the connection in the description and releases it back into the pool allowing it to be used by others.

Both functions are also available in the promised pool:

let description = await pool.promises.beginTransaction()
try {
  await description.connection.promises.query(`
    SELECT * from my_table WITH (updlock, holdlock)
  `)
  // do some other stuff
  await pool.promises.commitTransaction(description)
} catch (err) {
  await pool.promises.rollbackTransaction(description)
  // log err
}

Lastly, a nice little promise-specific utlity has been added:

pool.promises.transaction(async function (description) {
  /* I'm inside a transaction */
  await description.connection.promises.query(`Do transaction query here`)
})

This calls the callback and wraps it inside of a transaction with auto commit on success and auto rollback on any thrown errors.

description link
next js example, note cant run driver on UI thread. todo-with-nextjs_msnodesqlv8
using in typescript msnodesqlv8_ts_sample
js example typings in IDE msnodesqlv8_yarn_sample
using sequelize msnodesqlv8-sequelize
using mssql msnodesqlv8_mssql_sample
using electron msnodesqlv8-electron
using react msnodesqlv8-react
import sql from 'msnodesqlv8'
import Connection = MsNodeSqlV8.Connection
import ConnectionPromises = MsNodeSqlV8.ConnectionPromises
async function t() {
    const connectionString  = "Driver={ODBC Driver 17 for SQL Server};Server=(localdb)\\node;Database=scratch;Trusted_Connection=yes;"
    const con:Connection = await sql.promises.open(connectString)
    const promises:ConnectionPromises  = con.promises
    const res = await promises.query('select @@servername as server')
    console.log(JSON.stringify(res, null, 4))
    await con.promises.close()
}

t().then(() => {
    console.log('closed')
})
const connectionString  = "Driver={ODBC Driver 17 for SQL Server};Server=(localdb)\\node;Database=scratch;Trusted_Connection=yes;"

const sql = require('msnodesqlv8')

const query = 'SELECT top 2 * FROM syscolumns'

async function runner() {
    console.log(`using connection '${connectionString}' run query '${query}'`)
    const res = await sql.promises.query(connectionString, query)
    console.log(JSON.stringify(res, null, 4))
}

runner().then(() => {
    console.log('done.')
}).catch(e => {
    console.error(e)
})

image

Release v5.1.0

12 Jul 18:34

Choose a tag to compare

Full Changelog: v4.5.0...v5.1.0

This release is in pre release stages of testing - it is a massive change

  1. we have moved from nan to napi node api to buld the cpp
  2. added extensive logging that can be switched on to see exactly what driver is doing
  3. now building and testing with git actions.
  4. we only support ubuntu glib 2204 or later, if you run on earlier linux you have to build the driver yourself
  5. as much as possible drop in replacement to previous version < 5 of the driver.
  6. we no longer support anything less than node 20, electron 30
  7. we no longer support win32
  8. we build for windows, linux and mac os latest versions
  9. alpine linux will be a best effort but this is no longer considered in scope for supported builds.
image

This adds some much needed support for doing transactions from a pool with a few helper utilities.
Notable new API methods:

pool.beginTransaction(function (err, description) { /* description.connection.query() */ })

Pulls a connection information out of the pool and gives it to the caller. This connection becomes busy for the duration until either of next two functions are called:

pool.commitTransaction(description, function(err) { /* err logging */ })

Calls IF (@@TRANCOUNT > 0) COMMIT TRANSACTION on the connection in the description and releases it back into the pool allowing it to be used by others.

pool.rollbackTransaction(description, function(err) { /* err logging */ })

Calls IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION on the connection in the description and releases it back into the pool allowing it to be used by others.

Both functions are also available in the promised pool:

let description = await pool.promises.beginTransaction()
try {
  await description.connection.promises.query(`
    SELECT * from my_table WITH (updlock, holdlock)
  `)
  // do some other stuff
  await pool.promises.commitTransaction(description)
} catch (err) {
  await pool.promises.rollbackTransaction(description)
  // log err
}

Lastly, a nice little promise-specific utlity has been added:

pool.promises.transaction(async function (description) {
  /* I'm inside a transaction */
  await description.connection.promises.query(`Do transaction query here`)
})

This calls the callback and wraps it inside of a transaction with auto commit on success and auto rollback on any thrown errors.

description link
next js example, note cant run driver on UI thread. todo-with-nextjs_msnodesqlv8
using in typescript msnodesqlv8_ts_sample
js example typings in IDE msnodesqlv8_yarn_sample
using sequelize msnodesqlv8-sequelize
using mssql msnodesqlv8_mssql_sample
using electron msnodesqlv8-electron
using react msnodesqlv8-react
import sql from 'msnodesqlv8'
import Connection = MsNodeSqlV8.Connection
import ConnectionPromises = MsNodeSqlV8.ConnectionPromises
async function t() {
    const connectionString  = "Driver={ODBC Driver 17 for SQL Server};Server=(localdb)\\node;Database=scratch;Trusted_Connection=yes;"
    const con:Connection = await sql.promises.open(connectString)
    const promises:ConnectionPromises  = con.promises
    const res = await promises.query('select @@servername as server')
    console.log(JSON.stringify(res, null, 4))
    await con.promises.close()
}

t().then(() => {
    console.log('closed')
})
const connectionString  = "Driver={ODBC Driver 17 for SQL Server};Server=(localdb)\\node;Database=scratch;Trusted_Connection=yes;"

const sql = require('msnodesqlv8')

const query = 'SELECT top 2 * FROM syscolumns'

async function runner() {
    console.log(`using connection '${connectionString}' run query '${query}'`)
    const res = await sql.promises.query(connectionString, query)
    console.log(JSON.stringify(res, null, 4))
}

runner().then(() => {
    console.log('done.')
}).catch(e => {
    console.error(e)
})

image

v5.0.0 NAPI node api

28 Jun 15:14

Choose a tag to compare

This release is in pre release stages of testing - it is a massive change

  1. we have moved from nan to napi node api to buld the cpp
  2. added extensive logging that can be switched on to see exactly what driver is doing
  3. now building and testing with git actions.
  4. we only support ubuntu glib 2204 or later, if you run on earlier linux you have to build the driver yourself
  5. as much as possible drop in replacement to previous version < 5 of the driver.
  6. we no longer support anything less than node 20, electron 30
  7. we no longer support win32
  8. we build for windows, linux and mac os latest versions
  9. alpine linux will be a best effort but this is no longer considered in scope for supported builds.
image

This adds some much needed support for doing transactions from a pool with a few helper utilities.
Notable new API methods:

pool.beginTransaction(function (err, description) { /* description.connection.query() */ })

Pulls a connection information out of the pool and gives it to the caller. This connection becomes busy for the duration until either of next two functions are called:

pool.commitTransaction(description, function(err) { /* err logging */ })

Calls IF (@@TRANCOUNT > 0) COMMIT TRANSACTION on the connection in the description and releases it back into the pool allowing it to be used by others.

pool.rollbackTransaction(description, function(err) { /* err logging */ })

Calls IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION on the connection in the description and releases it back into the pool allowing it to be used by others.

Both functions are also available in the promised pool:

let description = await pool.promises.beginTransaction()
try {
  await description.connection.promises.query(`
    SELECT * from my_table WITH (updlock, holdlock)
  `)
  // do some other stuff
  await pool.promises.commitTransaction(description)
} catch (err) {
  await pool.promises.rollbackTransaction(description)
  // log err
}

Lastly, a nice little promise-specific utlity has been added:

pool.promises.transaction(async function (description) {
  /* I'm inside a transaction */
  await description.connection.promises.query(`Do transaction query here`)
})

This calls the callback and wraps it inside of a transaction with auto commit on success and auto rollback on any thrown errors.

description link
next js example, note cant run driver on UI thread. todo-with-nextjs_msnodesqlv8
using in typescript msnodesqlv8_ts_sample
js example typings in IDE msnodesqlv8_yarn_sample
using sequelize msnodesqlv8-sequelize
using mssql msnodesqlv8_mssql_sample
using electron msnodesqlv8-electron
using react msnodesqlv8-react
import sql from 'msnodesqlv8'
import Connection = MsNodeSqlV8.Connection
import ConnectionPromises = MsNodeSqlV8.ConnectionPromises
async function t() {
    const connectionString  = "Driver={ODBC Driver 17 for SQL Server};Server=(localdb)\\node;Database=scratch;Trusted_Connection=yes;"
    const con:Connection = await sql.promises.open(connectString)
    const promises:ConnectionPromises  = con.promises
    const res = await promises.query('select @@servername as server')
    console.log(JSON.stringify(res, null, 4))
    await con.promises.close()
}

t().then(() => {
    console.log('closed')
})
const connectionString  = "Driver={ODBC Driver 17 for SQL Server};Server=(localdb)\\node;Database=scratch;Trusted_Connection=yes;"

const sql = require('msnodesqlv8')

const query = 'SELECT top 2 * FROM syscolumns'

async function runner() {
    console.log(`using connection '${connectionString}' run query '${query}'`)
    const res = await sql.promises.query(connectionString, query)
    console.log(JSON.stringify(res, null, 4))
}

runner().then(() => {
    console.log('done.')
}).catch(e => {
    console.error(e)
})

image

v4.5.0

09 Feb 14:24
be43ddf

Choose a tag to compare

Automated release for v4.5.0, replicating previous assets.

24/05/2025 added node v24 binaries

What's Changed

This adds some much needed support for doing transactions from a pool with a few helper utilities.
Notable new API methods:

pool.beginTransaction(function (err, description) { /* description.connection.query() */ })

Pulls a connection information out of the pool and gives it to the caller. This connection becomes busy for the duration until either of next two functions are called:

pool.commitTransaction(description, function(err) { /* err logging */ })

Calls IF (@@TRANCOUNT > 0) COMMIT TRANSACTION on the connection in the description and releases it back into the pool allowing it to be used by others.

pool.rollbackTransaction(description, function(err) { /* err logging */ })

Calls IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION on the connection in the description and releases it back into the pool allowing it to be used by others.

Both functions are also available in the promised pool:

let description = await pool.promises.beginTransaction()
try {
  await description.connection.promises.query(`
    SELECT * from my_table WITH (updlock, holdlock)
  `)
  // do some other stuff
  await pool.promises.commitTransaction(description)
} catch (err) {
  await pool.promises.rollbackTransaction(description)
  // log err
}

Lastly, a nice little promise-specific utlity has been added:

pool.promises.transaction(async function (description) {
  /* I'm inside a transaction */
  await description.connection.promises.query(`Do transaction query here`)
})

This calls the callback and wraps it inside of a transaction with auto commit on success and auto rollback on any thrown errors.

Full Changelog: v4.3.0...v4.5.0

description link
next js example, note cant run driver on UI thread. todo-with-nextjs_msnodesqlv8
using in typescript msnodesqlv8_ts_sample
js example typings in IDE msnodesqlv8_yarn_sample
using sequelize msnodesqlv8-sequelize
using mssql msnodesqlv8_mssql_sample
using electron msnodesqlv8-electron
import sql from 'msnodesqlv8'
import Connection = MsNodeSqlV8.Connection
import ConnectionPromises = MsNodeSqlV8.ConnectionPromises
async function t() {
    const connectionString  = "Driver={ODBC Driver 17 for SQL Server};Server=(localdb)\\node;Database=scratch;Trusted_Connection=yes;"
    const con:Connection = await sql.promises.open(connectString)
    const promises:ConnectionPromises  = con.promises
    const res = await promises.query('select @@servername as server')
    console.log(JSON.stringify(res, null, 4))
    await con.promises.close()
}

t().then(() => {
    console.log('closed')
})
const connectionString  = "Driver={ODBC Driver 17 for SQL Server};Server=(localdb)\\node;Database=scratch;Trusted_Connection=yes;"

const sql = require('msnodesqlv8')

const query = 'SELECT top 2 * FROM syscolumns'

async function runner() {
    console.log(`using connection '${connectionString}' run query '${query}'`)
    const res = await sql.promises.query(connectionString, query)
    console.log(JSON.stringify(res, null, 4))
}

runner().then(() => {
    console.log('done.')
}).catch(e => {
    console.error(e)
})

image

4.4.0

18 Nov 21:15
6e9af43

Choose a tag to compare

description link
next js example, note cant run driver on UI thread. todo-with-nextjs_msnodesqlv8
using in typescript msnodesqlv8_ts_sample
js example typings in IDE msnodesqlv8_yarn_sample
using sequelize msnodesqlv8-sequelize
using mssql msnodesqlv8_mssql_sample
  1. update packages to latest
  2. fix for node-gyp build on node 22, node 23
import sql from 'msnodesqlv8'
import Connection = MsNodeSqlV8.Connection
import ConnectionPromises = MsNodeSqlV8.ConnectionPromises
async function t() {
    const connectionString  = "Driver={ODBC Driver 17 for SQL Server};Server=(localdb)\\node;Database=scratch;Trusted_Connection=yes;"
    const con:Connection = await sql.promises.open(connectString)
    const promises:ConnectionPromises  = con.promises
    const res = await promises.query('select @@servername as server')
    console.log(JSON.stringify(res, null, 4))
    await con.promises.close()
}

t().then(() => {
    console.log('closed')
})
const connectionString  = "Driver={ODBC Driver 17 for SQL Server};Server=(localdb)\\node;Database=scratch;Trusted_Connection=yes;"

const sql = require('msnodesqlv8')

const query = 'SELECT top 2 * FROM syscolumns'

async function runner() {
    console.log(`using connection '${connectionString}' run query '${query}'`)
    const res = await sql.promises.query(connectionString, query)
    console.log(JSON.stringify(res, null, 4))
}

runner().then(() => {
    console.log('done.')
}).catch(e => {
    console.error(e)
})

image

electron v29,v30,v31,v32 node v22,v23

23 Apr 21:03
485dc1a

Choose a tag to compare

description link
next js example, note cant run driver on UI thread. todo-with-nextjs_msnodesqlv8
using in typescript msnodesqlv8_ts_sample
js example typings in IDE msnodesqlv8_yarn_sample
using sequelize msnodesqlv8-sequelize
using mssql msnodesqlv8_mssql_sample
  1. release binaries for electron v29,v30,v31,v32 (v28 not supported, v32 needs 020 compiler) #324
  2. node v22, v23 binaries
  3. patch PR from contributor on date parsing #318
  4. update packages to latest
  5. reworked typings to better interop with JS/TS
import sql from 'msnodesqlv8'
import Connection = MsNodeSqlV8.Connection
import ConnectionPromises = MsNodeSqlV8.ConnectionPromises
async function t() {
    const connectionString  = "Driver={ODBC Driver 17 for SQL Server};Server=(localdb)\\node;Database=scratch;Trusted_Connection=yes;"
    const con:Connection = await sql.promises.open(connectString)
    const promises:ConnectionPromises  = con.promises
    const res = await promises.query('select @@servername as server')
    console.log(JSON.stringify(res, null, 4))
    await con.promises.close()
}

t().then(() => {
    console.log('closed')
})
const connectionString  = "Driver={ODBC Driver 17 for SQL Server};Server=(localdb)\\node;Database=scratch;Trusted_Connection=yes;"

const sql = require('msnodesqlv8')

const query = 'SELECT top 2 * FROM syscolumns'

async function runner() {
    console.log(`using connection '${connectionString}' run query '${query}'`)
    const res = await sql.promises.query(connectionString, query)
    console.log(JSON.stringify(res, null, 4))
}

runner().then(() => {
    console.log('done.')
}).catch(e => {
    console.error(e)
})

image

v4.2.0: Merge pull request #326 from TimelordUK/electron.v29

22 Apr 17:59
485dc1a

Choose a tag to compare

4.1.2

16 Nov 22:23
667e528

Choose a tag to compare

NextJS patch

please see https://github.com/TimelordUK/todo-with-nextjs_msnodesqlv8

for a sample NextJS application using msnodesqlv8

v4.1.1

24 Sep 16:22
9a8716d

Choose a tag to compare

  1. electron v27 binaries
  2. node v21 binaries

v4.1.0

22 May 20:06
46b0c00

Choose a tag to compare

typescript users note types are now split into their own module

import { Error, PoolOptions, Query, SqlClient, QueryDescription, Pool, PoolStatusRecord } from 'msnodesqlv8/types'
const sql: SqlClient = require('msnodesqlv8')
  1. #284

proven solution for Debian, Ubuntu running node 18, 20 experiencing SEGV core dump - install from src openssl 3.2

see appveyor and tool/openssl.sh

  1. #285

tested platforms

OS Node Version ODBC Version SSL version action
Windows 10 12, 14, 16, 18, 20 17, 18 leave default
Windows 11 18, 20 18 leave default
Ubuntu 22.04.2 18, 20 17, 18 openssl 3.2 e.g. tool/openssl.sh
Ubuntu 20.04 18, 20 18 openssl 3.2 e.g. tool/openssl.sh
Ubuntu 20.04 12, 14, 16 17, 18 openssl 1.1 leave default
Lubuntu 20.04 18, 20 18 openssl 3.2 e.g. tool/openssl.sh
Debian 18, 20 17, 18 openssl 3.2 e.g tool/openssl.sh
Alpine 3.16 18 18 openssl 1.1.1t leave default
MacOS Big Sur 18, 20 18 libressl 2.8.3 leave default
  1. #287 - unicode 16 bit col names

  2. electron 25 binaries

  3. electron 26 binaries