Can to create database using node-red?

I would like to create database of PostgreSQL using Node-RED, but when searching with "postgre" keyword, all nodes need to configure database name.

I tried to use the exec node but don't know what the input command is right.
Can I create the database using node-red?

Any idea will be great.

If the nodes don't support it, you will need to read up on the command line usage of PostgreSQL.

Once you can run the command from the command line, you can then translate that to the exec node.

1 Like

Normally to create database PostgreSQL from command-line I execute a script like below:

psql -U postgres
input password

In exec node, I enter psql -U postgres, the password entry line appears on the cmd side, after I enter password, the node-red side is still connected and not finished.

The translation of command-line to the exec node is how can you specify it to help me get it?

maybe look at the psql manual for ways to not have to pass the password

1 Like

Internet searches should always be your first port of call.

1 Like

@dceejay, @TotallyInformation The input password to login is necessary for security reasons, so I did not think that can set to bypass the password input so I did not ask google first, it bothers you @@.
Thanks for the instructions!

After setting up bypass password when executing command "psql -U postgres". I input the following command in the Command of exec node:

psql -U postgres;CREATE DATABASE dbTest;

...but still start entering the password of CREATE on the cmd side, I tried to enter the password of the postgres user and it got an error:

I did a google search but I don't know why entering this password.
Did I enter the command of PostgreSQL in Command of exec node correctly?

You probably don't want to append the payload in the exec node. Untick that option.

I have untick that option but the result still does not change,
still need to enter password of CREATE on the cmd side. :neutral_face:

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