tedious

How to insert data in Azure SQL using tedious.js after verifying that the data doesn't exists in the database?

落花浮王杯 提交于 2021-02-10 18:12:52
问题 This is the first time I'm using tedious.js , I still don't understand it a lot. I'm mostly going over their documentation here. Following is the logic in the POST method. Check if the tag already exists for the given statement id If the tag exists, return the message to the client If the tag doesn't exist, insert the tag in the database. This is my post method in express.js to add "tag" // POST add tags router.post('/tag', function(req, res){ // get the body const data = req.body; // sql

SQL tedious add array as parameter

爷,独闯天下 提交于 2021-02-09 02:49:07
问题 I'm running this SQL query with tedious.js using parameters: var query = "select * from table_name where id in (@ids)"; request = new sql.Request(query, function(err, rowCount) { if (err) { } }); request.on('row', function(columns) { }); var id = [1, 2, 3]; request.addParameters('ids', TYPES.Int, id); connection.execSql(request); because I am looking for items that matches the ID provided with where ... in ... clause, I need to pass in an array. However, there is no TYPES.Array. How do I this

Azure web app tedious

允我心安 提交于 2021-02-08 09:50:18
问题 I want to use use tedious in my Azure web app to follow this tutorial https://docs.microsoft.com/en-us/azure/sql-database/sql-database-connect-query-nodejs I get the error "Uncaught Error: Module name "tedious" has not been loaded yet" with require('tedious').Connection. How do I load this module in Azure? The javascript code: var Connection = require('tedious').Connection; var Request = require('tedious').Request; // Create connection to database var config = { userName: '******', // update

Sequelize/tedious table UPDATE on SQL Server 2005 table with triggers fails

为君一笑 提交于 2021-01-29 04:34:38
问题 Using tedious 1.14 sequelize 3.29 node 6.9.4 Connecting to: SQL Server 2005 on Windows Server 2008 R2 Std Node console output (attempted DML): Executing (default): UPDATE [OtifOrders] SET [onTime]=N'Short Lead Time / Add On',[inFull]=N'Product Substitution' OUTPUT INSERTED.* WHERE [orderNumber] = N'1024098924-1' PATCH /api/otiforders/1024098924-1 500 302.990 ms - - SQL Server error message from profiler: The target table OtifOrders of the DML statement cannot have any enabled triggers if the

Tedious or Sequelize uses the wrong syntax for `findOne()`

。_饼干妹妹 提交于 2020-08-21 18:46:37
问题 I am using Sequelize with Tedious to access SQL Server 2008. When I do a sequelizeModel.findOne() I get this exception - Unhandled rejection SequelizeDatabaseError: Invalid usage of the option NEXT in the FETCH statement. I know SQL Server 2008 doesn't support OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY and that is why the exception is thrown. But I have also explicitly set the tdsVersion in the tedious options to 7_3_B . As described here - http://pekim.github.io/tedious/api-connection.html I've

Tedious or Sequelize uses the wrong syntax for `findOne()`

假如想象 提交于 2020-08-21 18:45:27
问题 I am using Sequelize with Tedious to access SQL Server 2008. When I do a sequelizeModel.findOne() I get this exception - Unhandled rejection SequelizeDatabaseError: Invalid usage of the option NEXT in the FETCH statement. I know SQL Server 2008 doesn't support OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY and that is why the exception is thrown. But I have also explicitly set the tdsVersion in the tedious options to 7_3_B . As described here - http://pekim.github.io/tedious/api-connection.html I've

Understanding JS callbacks w/ Azure Functions & Tedious SQL

送分小仙女□ 提交于 2020-06-27 04:06:07
问题 The following code is for an Azure Function (Serverless) Http endpoint. The code uses the Tedious NPM package for connecting to an Azure SQL database. The challenge I am having, is understanding how to properly return the results from the callback behavior prior to the function exiting. Ideally, I'd like to do all my SQL work done synchronously in-line, without the callback behavior, but I understand that may not be best practice. Can anyone explain how this code could be modified to better

Sequelize connection and logging issues

孤人 提交于 2020-01-24 20:45:06
问题 I am trying to use Sequelize to connect with a SQL Server 2012 database. When my connection string was clearly wrong, I was seeing ECONN REFUSED messages and timeout. Now, I am not getting any response, despite logging on success and fail, per this code: import * as Sequelize from 'sequelize'; -- connection string redacted let seqConn = new Sequelize("mssql://**;Initial Catalog=**;Persist Security Info=True;Integrated Security=SSPI; User ID=**; Password=**") seqConn .authenticate() .then

How to set the Application Name for a Sequelize application

与世无争的帅哥 提交于 2020-01-03 18:58:55
问题 I've got a nodejs application that uses Sequelize as it's ORM. I've successfully got Sequelize connected to the database, but I haven't found anything in the documentation that explains how to set the application name. To clarify I'm looking to set a unique Application Name attribute for my app's connection string. That way when a DBA is looking at traffic they can pick out my application's queries from the rest. Is this something that Sequelize can even do? Or does this need to be done at

Can't connect Node.js server to Azure SQL Database

拜拜、爱过 提交于 2019-12-25 07:35:33
问题 I'm running a simple Node.js server on Heroku. I've set up an Azure SQL database and I'm just trying to establish a connection to it from the server. I'm using tedious.js to connect. As far as I can tell, I'm following the patterns in the docs, but the connection doesn't go through. This is the code I have (altered username and password). For now, the connect function is called upon a GET request to the "/data" page from my browser, but the page never loads and the connection never goes