import sql from 'mssql';
const sqlConfig = {
user: 'test',
password: 'test',
database: 'test',
server: 'test.test.com',
options: {
encrypt: false,
trustServerCertificate: true // change to true for local dev / self-signed certs
}
}
export default defineComponent({
async run({ steps, $ }) {
try {
let pool = await sql.connect(sqlConfig);
await pool.request()
.input('a', sql.VarChar(50), steps.trigger.event.body.string1)
.input('b', sql.VarChar(50), steps.trigger.event.body.string2)
.input('c', sql.VarChar(50), steps.trigger.event.body.string3)
.query('insert test_order(field1, field2, field3) values(@a, @b, @c)');
pool.close;
sql.close;
} catch (err) {
console.log(err)
}
},
})
I’ve got this error when connecting to sql server.
at null.null (/tmp/__pdg__/dist/code/e7743027e05bf27bed02d89916a793eddf1d96c6905e3846cb9d234cea53bff3/node_modules/.pnpm/mssql@9.1.0/node_modules/mssql/lib/tedious/connection-pool.js:70:17)
at Connection.onConnect (/tmp/__pdg__/dist/code/e7743027e05bf27bed02d89916a793eddf1d96c6905e3846cb9d234cea53bff3/node_modules/.pnpm/tedious@15.1.2/node_modules/tedious/lib/connection.js:1012:9)
at Object.onceWrapper (events.js:520:26)
at Connection.emit (events.js:400:28)
at Connection.emit (/tmp/__pdg__/dist/code/e7743027e05bf27bed02d89916a793eddf1d96c6905e3846cb9d234cea53bff3/node_modules/.pnpm/tedious@15.1.2/node_modules/tedious/lib/connection.js:1040:18)
at Connection.connectTimeout (/tmp/__pdg__/dist/code/e7743027e05bf27bed02d89916a793eddf1d96c6905e3846cb9d234cea53bff3/node_modules/.pnpm/tedious@15.1.2/node_modules/tedious/lib/connection.js:1254:10)
at Timeout.null (/tmp/__pdg__/dist/code/e7743027e05bf27bed02d89916a793eddf1d96c6905e3846cb9d234cea53bff3/node_modules/.pnpm/tedious@15.1.2/node_modules/tedious/lib/connection.js:1199:12)
at null.listOnTimeout (internal/timers.js:557:17)
at process.processTimers (internal/timers.js:500:7)
{
code: ‘ETIMEOUT’,
originalError: at Connection.connectTimeout (/tmp/pdg/dist/code/e7743027e05bf27bed02d89916a793eddf1d96c6905e3846cb9d234cea53bff3/node_modules/.pnpm/tedious@15.1.2/node_modules/tedious/lib/connection.js:1254:26)
at Timeout.null (/tmp/pdg/dist/code/e7743027e05bf27bed02d89916a793eddf1d96c6905e3846cb9d234cea53bff3/node_modules/.pnpm/tedious@15.1.2/node_modules/tedious/lib/connection.js:1199:12)
at null.listOnTimeout (internal/timers.js:557:17)
at process.processTimers (internal/timers.js:500:7)
{
code: ‘ETIMEOUT’,
isTransient: undefined
},
name: ‘ConnectionError’
}
