Re: Howto import regularly some CSV files with variing names?

From: Rowan Collins <rowan(dot)collins(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Howto import regularly some CSV files with variing names?
Date: 2013-09-24 19:23:46
Message-ID: 5241E6C2.9090107@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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]

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rowan Collins 2013-09-24 19:25:24 Re: Howto import regularly some CSV files with variing names?
Previous Message Rémi Cura 2013-09-24 17:18:31 Re: Howto import regularly some CSV files with variing names?