How to set env variable

Have a look in the node red docs.

Possibly the best way would be to first look at the code of the current node, then when you think you understand it, fork that repository and amend that node to do what you want. Once it is working you can send the changes back to the author as a PR to get it included in the standard node.
In fact first raise an issue on the node and offer to help the author implement the feature.

Again that won't work if the node makes a connection to the DB on startup and does not have the code to disconnect and connect to a different db.

This would have to be an optional behaviour if you wanted to update the existing node. Having to check then closing and reopening the connection all the time could potentially make the performance really bad if not implemented properly.

Wanted to know if this still is the case ? I could not see any documentation on this.

I was able to set an env variiable using function node.

  1. On Set up :- Import process module into variable "process".
  2. On Start Up :- process.env.x="XXX";
  3. Now i am able to access x as env variable across the system.

I could use in a normal inject node.

1 Like

Hi,

There is now a node called: node-red-contrib-mysql2 that can absolutely do what you need. You set the configuration (including credentials) in a JSON object, and it will connect to multiple different MYSQL DB's. Obviously it introduces the risk of people getting your DB credentials from the Node-RED flow, but I was willing to make that trade-off.

Cheers,

Paul