Skip to content

4.4.0

Latest
Compare
Choose a tag to compare
@TimelordUK TimelordUK released this 18 Nov 21:15
· 24 commits to master since this release
6e9af43
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