Jump to content

LabVIEW with PostgreSQL psql.exe password request


Recommended Posts

I am trying to connect a PostgreSQL database (ver 9.6) with LabVIEW (2016) on Windows 10.

I followed the following tutorial:

https://decibel.ni.com/content/docs/DOC-30308

Without access to a cRIO, I have followed the steps to create the database, table and block diagram. Please see block diagram attached.The system exec.vi calls the psql.exe with SELECT command using database "lisam" and database user "postgres".

When I execute the same code I am asked for the password for user postgres. When I type in the password, the box closes and reopens. This continues in a loop until I press abort. I get no errors and when I write the same script into the cmd - the password is accepted and the table is displayed, see attachment.

PROBLEM:

  • Password request from the psql.exe file when executing LabVIEW code
  • Type password, psql.exe closes and opens again
  • SELECT query works without while loop (password accepted once) but insert and clear does not without the loop condition

What I've tried...

  1. Created a pgpass.conf file in a postgresql folder in %AppData% in the following format:- hostname:port:database:username:password, where lisam is the database, postgres is the user.

Host name as localhost '127.0.0.1' - password still requested.

    127.0.0.1:5432:lisam:postgres:password

Host name as 'localhost' - psql.exe flashes continously and LabVIEW crashes. localhost:5432:database:username:password

Host name as database client address '::1' - password loop with the psql.exe.

    ::1:5432:database:username:password

Host name to '*' -

    *:5432:lisam:postgres:password

Able to:

  • Access the database through the cmd WITHOUT password

    C:/Program Files/PostgreSQL/9.6/bin/psql -c "SELECT * FROM demo1" lisam postgres

Problems:

  • Execution in Labview - psql.exe flashes continuously and the program crashes.
  • Accessing database through psql.exe directly - password requested and ERROR received
    "psql: FATAL: password authentication failed for user C:\Program Files"

2.Changed the authentication method in pg_hba.conf to trust for:

  • localhost (127.0.0.1)- a password is still requested.
  • 127.0.0.1 AND ::1 - Can access the database on psql without a password, but the psql.exe LabVIEW completely crashes.

    1. I tried adding the host and port to the code

      C:/Program Files/PostgreSQL/9.6/bin/psql -c "%s" -h 127.0.0.1 -p 5432 lisam postgres

And the psql.exe flashes continously and won't abort.

  1. The password is called at the system exec VI in the cmd. Tried concatenating the password (as a control) with space constant to the command line string inbetween the format into string and the system exec VI. But the password is given before it is called.

In summary I am able to use .pgpass.conf to authenticate the password when using the cmd, but not in LabVIEW. Does anyone know a way around this? Or another way to define the password at the system exec VI?

Your help is greatly needed.

Lisa


Info:

  • database name: lisam
  • database user: postgres

IPv4 local connections-

    host all all 127.0.0.1/32 md5

IPv6 local connections-

    host all all ::1/128 md5

    DB:lisam Client Address ::1
    psql Client address 127.0.0.1

 

 

 

PostgreSQL with LabVIEW.png

cmd.png

Edited by lisam
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.