Logging data in to SQL

Hi folks,
I am struggling to log data in to sql server.The flow is as below.
{ "id": "a1c0b421efb5920a", "type": "inject", "z": "f11c6d5ea7db963e", "name": "ping", "props": [ { "p": "payload" }, { "p": "topic", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "data1", "payloadType": "global", "x": 350, "y": 160, "wires": [ [ "0c3376d527d8aab2" ] ] }, { "id": "0c3376d527d8aab2", "type": "MSSQL", "z": "f11c6d5ea7db963e", "mssqlCN": "e02ffe57d2be552f", "name": "", "query": "INSERT INTO FLOWMETER\n(PERIOD,FLOWRATE1,TOTAL1,FLOWRATE2,TOTAL2,FLOWRATE3,TOTAL3)\nVALUES\n(GETDATE(),{{{global.data1}}},{{{global.data1}}},{{{global.data1}}},{{{global.data1}}},{{{global.data1}}},{{{global.data1}}})\n", "outField": "payload", "x": 540, "y": 160, "wires": [ [ "1ab6dbcbc5489960" ] ] }, { "id": "1ab6dbcbc5489960", "type": "debug", "z": "f11c6d5ea7db963e", "name": "debug 4", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 680, "y": 160, "wires": [] }, { "id": "e02ffe57d2be552f", "type": "MSSQL-CN", "name": "", "server": "localhost", "encyption": false, "database": "PRESS_LOG" } ]
Please help!

Hi, first get rid of that 7y old problematic node and install mssql-plus (see: Mssql not sending data to database using mustache format - #4 by Steve-Mcl)

Then, stop using dynamic queries (to avoid SQL injection hacks) and use parameters. Here is an example of how with mssql-plus: Mssql not sending data to database using mustache format - #2 by Steve-Mcl

I get an error as given when initiating installation of node.

"23-12-22T07:56:18.457Z Install : node-red-contrib-mssql-plus 0.12.1

2023-12-22T07:56:18.474Z npm.cmd install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production --engine-strict node-red-contrib-mssql-plus@0.12.1

2023-12-22T07:56:19.599Z [err] npm

2023-12-22T07:56:19.599Z [err] WARN config production Use --omit=dev instead.

2023-12-22T07:56:27.529Z [err] npm

2023-12-22T07:56:27.529Z [err] ERR! code

2023-12-22T07:56:27.529Z [err] EBADENGINE

2023-12-22T07:56:27.532Z [err] npm ERR! engine Unsupported engine

2023-12-22T07:56:27.532Z [err] npm ERR! engine Not compatible with your version of node/npm: @azure/core-rest-pipeline@1.13.0

2023-12-22T07:56:27.532Z [err] npm ERR! notsup Not compatible with your version of node/npm: @azure/core-rest-pipeline@1.13.0

2023-12-22T07:56:27.532Z [err] npm

2023-12-22T07:56:27.532Z [err] ERR! notsup Required: {"node":">=18.0.0"}

2023-12-22T07:56:27.532Z [err] npm

2023-12-22T07:56:27.532Z [err] ERR! notsup Actual: {"npm":"8.15.0","node":"v16.17.0"}

2023-12-22T07:56:27.536Z [err]

2023-12-22T07:56:27.536Z [err] npm ERR! A complete log of this run can be found in:

2023-12-22T07:56:27.536Z [err] npm

2023-12-22T07:56:27.536Z [err] ERR! C:\Users\Administrator\AppData\Local\npm-cache_logs\2023-12-22T07_56_19_570Z-debug-0.log

2023-12-22T07:56:27.572Z rc=1 "

Seems I need to upgrade node red version but I have a project already running on this version.

What version of node are you running?

Version - 16.17, but I have another system where this node works which was installed a few months back with this version.

I guess the recent update ( 2 months ago) has rendered it incompatible.

Is there a way to install the previous version of the node?

Yes. from inside your node-red folder (i'm guessing C:\Users\Administrator\.node-red)...

npm i node-red-contrib-mssql-plus@0.10.2

Forgot to say. Node 16 is now EOL (since sept) so the better solution is to upgrade to v18 LTS

Hey,
That worked ..Thanks!..but what did you want me to find the node red folder?..I ran the command in cmd prompt and it got installed..

What folder were you in when you ran that?

I ran from desktop

Well that should not have installed it in the right place, so I don't understand how it could have worked.

Are you saying the node wouldnt even appear or that it wont work as expected?

If the node is installed when the current folder is not the folder where the flows and settings files are (for a normal install of node red) then the node will not appear in the palette as, from node-red's point of view, it is not installed.

Edit: If you look in Manage Palette what version of the node does it say is in use?

Well, it says 0.10.2, which is what I installed..

I have no explanation for how that is.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.