Re: COPY FROM in psql

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Matthew Vernon <matthew(dot)vernon(at)sac(dot)ac(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: COPY FROM in psql
Date: 2012-11-20 19:05:01
Message-ID: 11307.1353438301@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Matthew Vernon <matthew(dot)vernon(at)sac(dot)ac(dot)uk> writes:
> naiively, you might try:
> \set pwd '\'' `pwd` '\''
> COPY table FROM :pwd || '/relative/path/to/data' ;

Umm ... why don't you just use a relative path as-is, with \copy
instead of COPY?

\copy table from 'relative/path/to/data'

The server-side COPY is likely to give you a lot of permission
headaches, ie the server's userid will need to be able to read that
file and the directories above it.

If you really need to do this I'd suggest doing the path-stitching
in the \set:

\set target '\'' `pwd` '/relative/path/to/data\''
COPY table FROM :target ;

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas 2012-11-20 19:06:49 Re: Experiences with pl/Java
Previous Message Rob Sargent 2012-11-20 19:03:10 Re: COPY FROM in psql