# Would a subflow environment variable be able to set a password for a Database?

**URL:** <https://discourse.nodered.org/t/would-a-subflow-environment-variable-be-able-to-set-a-password-for-a-database/61958>\
**Category:** General\
**Created:** [29 April 2022 10:30 UTC](https://discourse.nodered.org/t/would-a-subflow-environment-variable-be-able-to-set-a-password-for-a-database/61958 "2022-04-29T10:30:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shan](https://discourse.nodered.org/u/Shan)\
**Post date:** [29 April 2022 10:30 UTC](https://discourse.nodered.org/t/would-a-subflow-environment-variable-be-able-to-set-a-password-for-a-database/61958/1 "2022-04-29T10:30:14Z")

</div>

Let's say I take an InfluxDB In node in a subflow and configure it to some default settings based on how my stack is i.e.,

- Database Address
- Database Port
- Default Database
- Username
- Password

## Subflow

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/1/018af8c3b86ec138bd45701562ba7c3d15af45c5.png)

### Subflow Environment Variables

Let the user have the ability to change the username / password / database via the Env Vars of the subflow

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/5/b56f73e2f0f324807fe4379a66b46a5fa4466588.png)

### InfluxDB Configuration

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/1/61e109a3523951d4b036309d10904522b4271918.png)

Would I be able to resolve the password using `$(password)` in the dedicated `Password` field of the InfluxDB configuration?

---

<div class="post-metadata">

**Author:** ![Shan](https://avatars.discourse-cdn.com/v4/letter/s/7ab992/32.png) [@Shan](https://discourse.nodered.org/u/Shan)\
**Post date:** [29 April 2022 10:39 UTC](https://discourse.nodered.org/t/would-a-subflow-environment-variable-be-able-to-set-a-password-for-a-database/61958/2 "2022-04-29T10:39:23Z")

</div>

I tried it out and it works.

The following:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/9/292fca4be5f09f129047c5d99e2a36b5854d54eb.png)

will be able to obtain resolve the information from the Env Vars.

What one may not see is that the value of the **Password** is `$(password)`.

## Test flow

For the following flow where the function node is just

```auto
msg.query = "SHOW USERS";
return msg;

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/9/291c49a5ab0853727da2f9811019cdca7986591a.png)

The debug node is able to show values provided the user sets the password and username using the UI of the subflow

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [13 May 2022 10:39 UTC](https://discourse.nodered.org/t/would-a-subflow-environment-variable-be-able-to-set-a-password-for-a-database/61958/3 "2022-05-13T10:39:53Z")

</div>

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