COPY FROM in psql

From: Matthew Vernon <matthew(dot)vernon(at)sac(dot)ac(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: COPY FROM in psql
Date: 2012-11-20 18:46:13
Message-ID: 87wqxgt8oo.fsf@macbeth.sac.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

suppose for a moment I want to write a psql script that loads some data
into a database. I don't want to write an absolute path into my script,
but merely know where the data file will be relative to my script
location.

naiively, you might try:
\set pwd '\'' `pwd` '\''
COPY table FROM :pwd || '/relative/path/to/data' ;

but that doesn't work because the concatenation operator can't be used
there. How should I be doing this?

Thanks,

Matthew

--
Matthew Vernon
Quantitative Veterinary Epidemiologist
Epidemiology Research Unit, SAC Inverness

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Matthew Vernon 2012-11-20 18:47:48 Re: COPY FROM in psql
Previous Message Jeff Janes 2012-11-20 18:16:48 Re: High SYS CPU - need advise