Skip to main content
Question

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

  • September 24, 2019
  • 2 replies
  • 58 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.

2 replies

david_r
Evangelist
  • 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+17
  • 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.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings