- update packages to latest
- 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)
})