From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
10-19-2016 04:52 AM
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:
What I've tried...
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:
2.Changed the authentication method in pg_hba.conf to trust for:
127.0.0.1 AND ::1 - Can access the database on psql without a password, but the psql.exe LabVIEW completely crashes.
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.
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:
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
10-21-2016 05:51 AM
Hello Lisa,
Have you considered using the database connectivity toolkit?
http://www.ni.com/pdf/labview/us/database_connectivity_toolkit.pdf
Here also is a link to a forum page which talks through using postgreSQL with LabVIEW. I'm not a database expert, but I believe you should be able to interact with the database using ODBC drivers.
Best wishes,
Adam.
10-21-2016 06:09 AM - edited 10-21-2016 06:10 AM
Hi Adam,
Many thanks for your suggestion. I am currently testing a trial of the DB Connectivity Toolkit, but more for explorative purposes as the toolkit requires further licencing and costs (£££).
I managed to configure the postgres .pgpass file to automatically submit the password. This worked after placing the code in a sequence structure to give the system exec time to locate the password. So the code works now. I am now looking into making the process more efficient through connection pooling to keep the connection open. I've heard this can be done using ODBC drivers but I'm hoping I can do this without the Connectivity Toolkit to save money.
Do you have any knowledge with connection pooling?
Thanks again.
Lisa