Re: running \copy through perl dbi ?

Поиск
Список
Период
Сортировка
От Vincent Veyron
Тема Re: running \copy through perl dbi ?
Дата
Msg-id 20231208191259.ea787e20149bf6c3817e6cd4@wanadoo.fr
обсуждение исходный текст
Ответ на running \copy through perl dbi ?  (David Gauthier <dfgpostgres@gmail.com>)
Список pgsql-general
On Fri, 8 Dec 2023 10:45:28 -0500
David Gauthier <dfgpostgres@gmail.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



В списке pgsql-general по дате отправления:

Предыдущее
От: "peter.borissow@kartographia.com"
Дата:
Сообщение: Inserting into foreign table with sequences and default values
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Inserting into foreign table with sequences and default values