Mssql-plus issue with mustache format for server name and user/pwd

Hi,
I'm using mssql-plus 0.6.4 version.
Node red and node js version: not sure, using with Litmus edge

I could not connect to sql using env variable for connection informations. This is helpful for me to connect to different db located in the different location. I tried to create a sub flow for sql that would help me reuse the same flow across different locations with different servers.
It throws me an errr message
code: "ESOCKET"
message: "Failed to connect to :1433 - Could not connect (sequence)

you help would be really appreciable
I've attached the flow with subflow

[{"id":"ebc85c42.463a8","type":"subflow","name":"SQLPlus064","info":"","category":"","in":[{"x":100,"y":80,"wires":[{"id":"bf1289cd.07fcb8"}]}],"out":[{"x":300,"y":80,"wires":[{"id":"bf1289cd.07fcb8","port":0}]}],"env":[{"name":"ServerName","type":"str","value":"10.1.2.111"},{"name":"UserName","type":"str","value":"appliUser"},{"name":"Password","type":"str","value":"1234556"},{"name":"DBName","type":"str","value":"DB_DEV"}],"color":"#DDAA99"},{"id":"bf1289cd.07fcb8","type":"MSSQL","z":"ebc85c42.463a8","mssqlCN":"c29068d1.97ef38","name":"","outField":"payload","returnType":0,"throwErrors":1,"query":"Select TOP 10 * FROM TestBenchResult","modeOpt":"","modeOptType":"query","queryOpt":"","queryOptType":"editor","paramsOpt":"","paramsOptType":"none","params":[],"x":200,"y":80,"wires":[[]]},{"id":"c29068d1.97ef38","type":"MSSQL-CN","z":"ebc85c42.463a8","tdsVersion":"7_4","name":"DB-Con","server":"\"ServerName\"","port":"","encyption":true,"trustServerCertificate":true,"database":"ShopfloorDB_DEV","useUTC":false,"connectTimeout":"50000","requestTimeout":"50000","cancelTimeout":"50000","pool":"5","parseJSON":false,"enableArithAbort":true},{"id":"c81636eb.e7d248","type":"tab","label":"MSSQLPlus-CheckSub","disabled":false,"info":""},{"id":"7c1a36cd.c54a88","type":"inject","z":"c81636eb.e7d248","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":100,"wires":[["30366732.3efba8"]]},{"id":"de6a1325.7c759","type":"debug","z":"c81636eb.e7d248","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":440,"y":100,"wires":[]},{"id":"30366732.3efba8","type":"subflow:ebc85c42.463a8","z":"c81636eb.e7d248","name":"","env":[{"name":"ServerName","value":"10.1.2.111","type":"env"},{"name":"Password","value":"123456789","type":"str"}],"x":300,"y":80,"wires":[["de6a1325.7c759"]]}]

please let me know if you need any further details.

we really need this as we have more locations for which we cannot create different flows for same set of actions

Thanks
Ramesh R

I think this is not possible (via env variables) as the credentials are stored and encrypted separately - outside the flow file.
When exporting the flow, the credentials are not included (security).

Hi. I'm not able to provide assistance right now however I will say, env variables should work. Instead of using a subflow, could you try real env vars (in the executing environment - before you launch node-red) - do they work for you?

1 Like

But in the documentation, it is mentioned in the features list

Thanks
Ramesh R

Hi @Steve-Mcl ,
Sorry for my poor knowledge. I'm new to node-red.
So please excuse me if this may be a basic question

How do I set Environment variable for a normal flow?
Because I could not set in the executing env, I even googled but in vain

Thanks

Ah ok, i was not aware, that is a useful feature in these situations (if it works ofcourse ;))

Before launching node-red, set environmental variables in your terminal.

E.g. Windows CMD...

set server=192.168.0.99
node-red

E.g. Linux terminal

export server=192.168.0.99
node-red

Then use the variable...

E.g. {{server}}

( try double brackets instead of triple )

No. Use. ${server}. You aren’t using mustache here. And it can only be for the complete property.
see - Using environment variables : Node-RED

Sorry both ${server} and {{server}} not working