Re: COPY FROM in psql - Mailing list pgsql-general

From Tom Lane
Subject Re: COPY FROM in psql
Date
Msg-id 11307.1353438301@sss.pgh.pa.us
Whole thread Raw
In response to COPY FROM in psql  (Matthew Vernon <matthew.vernon@sac.ac.uk>)
List pgsql-general
Matthew Vernon <matthew.vernon@sac.ac.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


pgsql-general by date:

Previous
From: Rob Sargent
Date:
Subject: Re: COPY FROM in psql
Next
From: Thomas
Date:
Subject: Re: Experiences with pl/Java