Re: [GENERAL] COPY FROM in psql

2012-11-23 Thread Jasen Betts
On 2012-11-21, Matthew Vernon matthew.ver...@sac.ac.uk wrote: t...@sss.pgh.pa.us (Tom Lane) writes: Matthew Vernon matthew.ver...@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

Re: [GENERAL] COPY FROM in psql

2012-11-21 Thread Matthew Vernon
t...@sss.pgh.pa.us (Tom Lane) writes: Matthew Vernon matthew.ver...@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? Thanks for the

[GENERAL] COPY FROM in psql

2012-11-20 Thread Matthew Vernon
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

Re: [GENERAL] COPY FROM in psql

2012-11-20 Thread Matthew Vernon
Matthew Vernon matthew.ver...@sac.ac.uk writes: naiively, you might try: \set pwd '\'' `pwd` '\'' COPY table FROM :pwd || '/relative/path/to/data' ; I should also note that I want to run a series of these commands, hence setting pwd once and then wanting to use it multiple times. Matthew --

Re: [GENERAL] COPY FROM in psql

2012-11-20 Thread Rob Sargent
On 11/20/2012 11:47 AM, Matthew Vernon wrote: Matthew Vernon matthew.ver...@sac.ac.uk writes: naiively, you might try: \set pwd '\'' `pwd` '\'' COPY table FROM :pwd || '/relative/path/to/data' ; I should also note that I want to run a series of these commands, hence setting pwd once and then

Re: [GENERAL] COPY FROM in psql

2012-11-20 Thread Tom Lane
Matthew Vernon matthew.ver...@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

Re: [GENERAL] COPY FROM in psql

2012-11-20 Thread Matthew Vernon
Matthew Vernon matthew.ver...@sac.ac.uk writes: naiively, you might try: \set pwd '\'' `pwd` '\'' COPY table FROM :pwd || '/relative/path/to/data' ; so I could do: \set path '\'' `pwd` '/path/to/data1' '\'' COPY table1 FROM :path; \set path '\'' `pwd` '/path/to/data2' '\'' COPY table2 FROM