Обсуждение: COPY question
Hi,
I still get the same error while using COPY FROM 'file'. I have to pass the full directory for this to work, example:
COPY first (a,b,c) FROM '1st_file.csv' with csv header delimiter ',';
ERROR: could not open file "1st_file.csv" for reading: No such file or directory
The same when I use: '.1st_file.csv' or './1st_file.csv'.
No errors when I give the full path.
Giving the full path is stupid, how can I use just the file name?
[PostgreSQL 9.1alpha1 on x86_64-unknown-linux-gnu, compiled by GCC gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5, 64-bit]
regards
Szymon
On 21/10/2010 22:16, Szymon Guz wrote: > Hi, > I still get the same error while using COPY FROM 'file'. I have to pass > the full directory for this to work, example: > > COPY first (a,b,c) FROM '1st_file.csv' with csv header delimiter ','; > ERROR: could not open file "1st_file.csv" for reading: No such file or > directory > > The same when I use: '.1st_file.csv' or './1st_file.csv'. > > No errors when I give the full path. Yes, that's documented behaviour - you need to give the full path. > Giving the full path is stupid, how can I use just the file name? Why is it stupid? Ray. -- Raymond O'Donnell :: Galway :: Ireland rod@iol.ie
On 21 October 2010 23:28, Raymond O'Donnell <rod@iol.ie> wrote:
On 21/10/2010 22:16, Szymon Guz wrote:Yes, that's documented behaviour - you need to give the full path.Hi,>
I still get the same error while using COPY FROM 'file'. I have to pass
the full directory for this to work, example:
COPY first (a,b,c) FROM '1st_file.csv' with csv header delimiter ',';
ERROR: could not open file "1st_file.csv" for reading: No such file or
directoryThe same when I use: '.1st_file.csv' or './1st_file.csv'.
No errors when I give the full path.
I've noticed that already. Btw, I could use the file name, but it won't be searched in my current directory.
"The path will be interpreted relative to the working directory of the server process (normally the cluster's data directory), not the client's working directory."
Why is it stupid?Giving the full path is stupid, how can I use just the file name?
Because I can't just move my scripts/queries to some other directory, where I have files with the same names, but different content (just for tests).
Thanks for the answer.
regards
Szymon
On 10/22/2010 05:16 AM, Szymon Guz wrote: > Hi, > I still get the same error while using COPY FROM 'file'. I have to pass > the full directory for this to work, example: Sounds like you want to be using psql's \copy, not the server side COPY. \copy is aware of your current working directory and doesn't require the server to have permission to access the file - or even be on the same machine. -- Craig Ringer