Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const sql = require('mssql');
- const config = {
- user: 'reconcile',
- password: 'SenopatiPanembahan!23',
- server: 'midgard.etobee.com', // You can use 'localhost\\instance' to connect to named instance
- database: 'etobee_dbs'
- }
- exports.execSql = async function(sqlquery) {
- const pool = new sql.ConnectionPool(config);
- pool.on('error', err => {
- // ... error handler
- console.log('sql errors', err);
- });
- try {
- await pool.connect();
- let result = await pool.request().query(sqlquery);
- return result;
- } catch (err) {
- return {err: err};
- } finally {
- pool.close(); //closing connection after request is finished.
- }
- };
Add Comment
Please, Sign In to add comment