Skip to main content
Question

How to run postgresql script (psql -f file_with_sql.sql) in SQL executor

  • September 24, 2019
  • 2 replies
  • 83 views

Forum|alt.badge.img

I want to run bunch of postgreSQL SQL's through a file using psql command.

To check whether psql works in SQLExecutor, I tried putting below statement SQL executor.

psql -c 'SELECT * FROM testdb.test';

 

However, I got below error.

psql -c 'SELECT * FROM testdb.test';'): 'ERROR: syntax error at or near "psql"

LINE 3: psql -c 'SELECT * FROM testdb.test;

^

'

A fatal error has occurred. Check the logfile above for details

 

Can you please help.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

david_r
Celebrity
  • September 24, 2019

If it's really a psql script you should use the SystemCaller and call the psql command line tool there.

If the script contains regular SQL you can copy/paste the query itself into the SQLExecutor:

select * from testdb.test

Note that it does not include the semi-colon at the end.

 


erik_jan
Contributor
Forum|alt.badge.img+26
  • Contributor
  • September 24, 2019

If it reads from a table another option would be using the FeatureReader transformer.

You can point that transformer to the table or use the SQL statement to get the records.