Open jasong-au opened 10 months ago
I am afraid i do not have any association with this module, so cannot help - does this work?
import { createRequire } from 'module'
const require = createRequire(import.meta.url)
const sql= require('mssql/msnodesqlv8')
const connectionString = "Driver={ODBC Driver 17 for SQL Server};Server=(localdb)\\node;Database=scratch;Trusted_Connection=yes;"
const config = {
connectionString: connectionString
}
async function runner() {
const pool = await sql.connect(config)
const res = await pool.query('select top 3 * from syscolumns')
console.log(JSON.stringify(res, null, 4))
await pool.close()
}
runner().then(() => {
console.log('done')
})
The whole way that mssql and msnodesqlv8 work together seems wonky. It's taken a lot of time, but I got it to simply connect with plain javascript and using require. However I am trying to use it in a module (server-size sveltekit, but trying to get it working in node .mjs) and can't figure out how to get it to work without using 'require' which isn't supported. Any help or samples would be appreciated.