| From: | Vincent Veyron <vv(dot)lists(at)wanadoo(dot)fr> |
|---|---|
| To: | pgsql-general(at)lists(dot)postgresql(dot)org |
| Subject: | Re: running \copy through perl dbi ? |
| Date: | 2023-12-08 18:12:59 |
| Message-ID: | 20231208191259.ea787e20149bf6c3817e6cd4@wanadoo.fr |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Fri, 8 Dec 2023 10:45:28 -0500
David Gauthier <dfgpostgres(at)gmail(dot)com> wrote:
>
> I'm trying to run a PG client side "\copy" command from a perl script. I
> tried using $dbh->do("\\copy ...") but it barffed when it saw the '\'...
> ERROR: syntax error at or near "\"
Hi David,
This works for me :
#create file
my $sql = qq {\\copy ( $sub_query ) to '$location' with null as '' delimiter ';' csv header } ;
my $db_name = 'xxxxxx' ;
my @args = ( 'psql', '-c', $sql, $db_name ) ;
system( @args ) == 0 or die "Bad copy: $?" ;
--
Bien à vous, Vincent Veyron
https://marica.fr
Logiciel de gestion des contentieux juridiques, des contrats et des sinistres d'assurance
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2023-12-08 18:31:46 | Re: Inserting into foreign table with sequences and default values |
| Previous Message | peter.borissow@kartographia.com | 2023-12-08 18:03:58 | Inserting into foreign table with sequences and default values |