Re: Howto import regularly some CSV files with variing names? - Mailing list pgsql-general

From Rowan Collins
Subject Re: Howto import regularly some CSV files with variing names?
Date
Msg-id 5241E6C2.9090107@gmail.com
Whole thread Raw
In response to Re: Howto import regularly some CSV files with variing names?  (Rémi Cura <remi.cura@gmail.com>)
List pgsql-general
On 24/09/2013 18:18, Rémi Cura wrote:
> To be very straightforward :
> your bash script will dynamically create the sql query in a string,
> then send it to database using psql.
> You can also use pipes.
>
> For example :
> $4 -c "COPY $1 FROM '/tmp/pipe_ply_binaire_vers_ply_ascii_"$1"' WITH
> CSV DELIMITER AS ' ';";
>
> where $4 is the psql command to connect to db, $1 the number in the
> name of the file we are working in, etc

One problem with this is that it requires your shell script to have
superuser access to your database, since it is directly running a COPY
command. This may or may not matter, depending on setup - for instance,
you might trust local Unix sockets, meaning someone would need access to
the box first. It's probably best to never have a non-interactive
process able to connect with elevated privileges though.

--
Rowan Collins
[IMSoP]


pgsql-general by date:

Previous
From: Rémi Cura
Date:
Subject: Re: Howto import regularly some CSV files with variing names?
Next
From: Rowan Collins
Date:
Subject: Re: Howto import regularly some CSV files with variing names?