Search code examples
postgresqlcopytalend

Using Postgres "copy" command in Talend to load table content into CSV file


I have to copy few postgres table contents into a CSV file for further processing using Talend.

When I tried

copy table_name to ‘/tmp/export/table_name.csv’ with CSV;

with 'tpostgresqlRow' component, it threw error saying "Need superuser access", which I wouldn't be getting.

As an alternative, I tried "\copy" command as

\\copy table_name to ‘/tmp/export/table_name.csv’ with CSV;"

(first slash is used to escape the other). Still it threw error saying "Syntax error at '\'".

I tried with tpostgresqlBulkExec component as well, which internally uses "copy" command, and it as well threw error saying "Need superuser access".

Is there a way out to execute this postgres "copy" command in bulk using Talend?

Any help would be much appreciated.


Solution

  • I got confirmation from Talend Support Team that tPostgresqlRow component would not support 'COPY' command. I have resolved my case by installing PSQL client and calling the same using tSSH component in Talend to execute the desired 'COPY' commands.