Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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]


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux