LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to write data to a PostgreSQL database

Hi,

 

I am trying to write some data on LabVIEW and insert it into a local postgreSQL database. I tried to follow the example below (screen shot of example also attached) using format into the string function and system exec.VI:

 

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

 

I get an error message stating:

 

"Error 2 occurred at System Exec.vi. Command was /usr/bin/psql -c "SELECT * FROM test" mydb". Possible reason: LabVIEW memory is full?

 

I am using postgresql 9.6 and LabVIEW 2016.

 

Thanks in advance,

 

Lisa

0 Kudos
Message 1 of 7
(1,325 Views)

It appears that the error code is coming from your Command to read the database.  Have you verified that the database has been installed correctly and it is even possible to execute the Select command?

 

Try going to a command prompt and typing the following:

  • /usr/bin/psql -c "SELECT * FROM demo1" mydb

Did this do something that is "meaningful"?  What do you get from Standard Out and Standard Error?

 

If this works, try "by hand" the other psql commands.  Let us know the results.

 

Bob Schor

Message 2 of 7
(1,290 Views)

Hi thanks for your comment. I managed to get it to execute by finding the actual location of the psql.exe in my c drive. ..

 

C:/Program Files/PostgreSQL/9.6/bin/psql -c "%s" mydb

 

However now the psql.exe pops up asking for a password. Any ideas what this could be? or how to prevent the need for a password?

 

 

 

 

0 Kudos
Message 3 of 7
(1,283 Views)

 

 

0 Kudos
Message 4 of 7
(1,283 Views)

Now you are asking a PostgreSQL question.  Go to their site and see what they say.

 

Bob Schor

0 Kudos
Message 5 of 7
(1,262 Views)

@lisam88 wrote:

Hi thanks for your comment. I managed to get it to execute by finding the actual location of the psql.exe in my c drive. ..

 

C:/Program Files/PostgreSQL/9.6/bin/psql -c "%s" mydb

 

However now the psql.exe pops up asking for a password. Any ideas what this could be? or how to prevent the need for a password?


I would wager there's something like a -p option for providing a password.

/Y

G# - Award winning reference based OOP for LV, for free! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 7
(1,242 Views)

 Thanks for your help, it is much appreciated . In the psql guide there are only two options regarding passwords:

  • -w is for when there is no password
  • -W is to prompt for a password.

There is no option to provide the password as a command line argument because that information is often available to all users, and therefore insecure.

I have a password contained in configuration file .pgpass.conf. Perhaps I can put this into the labview code? Would you know how to do this?

0 Kudos
Message 7 of 7
(1,236 Views)