Thread: ERROR: relative path not allowed for COPY to file
I am using pgAdmin 14.1 and then tried with pgAdmin 16.1
I have tried:
COPY (select * from file) TO '”C:/Dev/test.csv”';
And get the error:
ERROR: relative path not allowed for COPY to file
SQL state: 42602
Also, when I try:
COPY temp_import FROM E'"C:/Dev/exponare_data_mgr/exponare_filelist.txt"';
I get the following error:
ERROR: could not open file ""C:/Dev/exponare_data_mgr/exponare_filelist.txt"" for reading: No such file or directory
SQL state: 58P01
I suspect that pgAdmin is not passing the filename in a manner, that the shell on windows7 ,interprets correctly.
I have also tried the same commands from the psql console and achieve the same results.
Under linux the commands work well.
Is there a suggestion for things I change/check to get COPY to work?
Cheers
Steven
_____________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed
Scanning Services - powered by MessageLabs. For further information
visit http://www.mci.com
Try \ instead
I am using pgAdmin 14.1 and then tried with pgAdmin 16.1
I have tried:
COPY (select * from file) TO '”C:/Dev/test.csv”';
And get the error:
ERROR: relative path not allowed for COPY to file
SQL state: 42602
Also, when I try:
COPY temp_import FROM E'"C:/Dev/exponare_data_mgr/exponare_filelist.txt"';
I get the following error:
ERROR: could not open file ""C:/Dev/exponare_data_mgr/exponare_filelist.txt"" for reading: No such file or directory
SQL state: 58P01
I suspect that pgAdmin is not passing the filename in a manner, that the shell on windows7 ,interprets correctly.
I have also tried the same commands from the psql console and achieve the same results.
Under linux the commands work well.
Is there a suggestion for things I change/check to get COPY to work?
Cheers
Steven
Check out all the latest news and events at Council on www.begavalley.nsw.gov.au.
_____________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed
Scanning Services - powered by MessageLabs. For further information
visit http://www.mci.com
Hi,
Here are the variations of slashes, sloshes and speech marks which have achieved the same (failed) outcome:
COPY (select * from file) TO '”C:\\Dev\\test.csv”';
COPY (select * from file) TO '”C:\Dev\test.csv”';
COPY (select * from file) TO '”C:/Dev/test.csv”';
COPY (select * from file) TO 'C:/Dev/test.csv';
COPY (select * from file) TO 'C:\Dev\test.csv';
COPY (select * from file) TO 'C:\\Dev\\test.csv';
COPY (select * from file) TO '\"C:\\Dev\\test.csv\"';
COPY (select * from file) TO '\"C:\Dev\test.csv\"';
COPY (select * from file) TO '\"C:/Dev/test.csv\"';
Is there somewhere that I can check what is actually being passed to the shell?
Or would I need to debug psql.exe?
cheers
Steven
Ps (thanks for the speedy response!)
From: Michael Shapiro [mailto:mshapiro51@gmail.com]
Sent: Friday, 15 February 2013 1:48 PM
To: Katona, Steve
Cc: pgadmin-support@postgresql.org
Subject: Re: [pgadmin-support] ERROR: relative path not allowed for COPY to file
It might be the /
Try \ instead
On Thu, Feb 14, 2013 at 8:43 PM, Katona, Steve <SKatona@begavalley.nsw.gov.au> wrote:
I am using pgAdmin 14.1 and then tried with pgAdmin 16.1
I have tried:
COPY (select * from file) TO '”C:/Dev/test.csv”';
And get the error:
ERROR: relative path not allowed for COPY to file
SQL state: 42602
Also, when I try:
COPY temp_import FROM E'"C:/Dev/exponare_data_mgr/exponare_filelist.txt"';
I get the following error:
ERROR: could not open file ""C:/Dev/exponare_data_mgr/exponare_filelist.txt"" for reading: No such file or directory
SQL state: 58P01
I suspect that pgAdmin is not passing the filename in a manner, that the shell on windows7 ,interprets correctly.
I have also tried the same commands from the psql console and achieve the same results.
Under linux the commands work well.
Is there a suggestion for things I change/check to get COPY to work?
Cheers
Steven
Check out all the latest news and events at Council on www.begavalley.nsw.gov.au.
_____________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed
Scanning Services - powered by MessageLabs. For further information
visit http://www.mci.com
_____________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed
Scanning Services - powered by MessageLabs. For further information
visit http://www.mci.com
_____________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed
Scanning Services - powered by MessageLabs. For further information
visit http://www.mci.com
Hi,
I have noticed that I receive a warning when opening a psql console from pgAdmin III.
Console code page (850) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
Page “Notes for Windows users” for details.
Could this be contributing to my problem?
Cheers
Steven
From: Michael Shapiro [mailto:mshapiro51@gmail.com]
Sent: Friday, 15 February 2013 1:48 PM
To: Katona, Steve
Cc: pgadmin-support@postgresql.org
Subject: Re: [pgadmin-support] ERROR: relative path not allowed for COPY to file
It might be the /
Try \ instead
On Thu, Feb 14, 2013 at 8:43 PM, Katona, Steve <SKatona@begavalley.nsw.gov.au> wrote:
I am using pgAdmin 14.1 and then tried with pgAdmin 16.1
I have tried:
COPY (select * from file) TO '”C:/Dev/test.csv”';
And get the error:
ERROR: relative path not allowed for COPY to file
SQL state: 42602
Also, when I try:
COPY temp_import FROM E'"C:/Dev/exponare_data_mgr/exponare_filelist.txt"';
I get the following error:
ERROR: could not open file ""C:/Dev/exponare_data_mgr/exponare_filelist.txt"" for reading: No such file or directory
SQL state: 58P01
I suspect that pgAdmin is not passing the filename in a manner, that the shell on windows7 ,interprets correctly.
I have also tried the same commands from the psql console and achieve the same results.
Under linux the commands work well.
Is there a suggestion for things I change/check to get COPY to work?
Cheers
Steven
Check out all the latest news and events at Council on www.begavalley.nsw.gov.au.
_____________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed
Scanning Services - powered by MessageLabs. For further information
visit http://www.mci.com
_____________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed
Scanning Services - powered by MessageLabs. For further information
visit http://www.mci.com
_____________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed
Scanning Services - powered by MessageLabs. For further information
visit http://www.mci.com
Files named in a COPY command are read or written directly by the server, not by the client application. Therefore, they must reside on or be accessible to the database server machine, not the client. They must be accessible to and readable or writable by the PostgreSQL user (the user ID the server runs as), not the client. COPY naming a file is only allowed to database superusers, since it allows reading or writing any file that the server has privileges to access.
I am using pgAdmin 14.1 and then tried with pgAdmin 16.1
I have tried:
COPY (select * from file) TO '”C:/Dev/test.csv”';
And get the error:
ERROR: relative path not allowed for COPY to file
SQL state: 42602
Also, when I try:
COPY temp_import FROM E'"C:/Dev/exponare_data_mgr/exponare_filelist.txt"';
I get the following error:
ERROR: could not open file ""C:/Dev/exponare_data_mgr/exponare_filelist.txt"" for reading: No such file or directory
SQL state: 58P01
I suspect that pgAdmin is not passing the filename in a manner, that the shell on windows7 ,interprets correctly.
I have also tried the same commands from the psql console and achieve the same results.
Under linux the commands work well.
Is there a suggestion for things I change/check to get COPY to work?
Cheers
Steven
Check out all the latest news and events at Council on www.begavalley.nsw.gov.au.
_____________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed
Scanning Services - powered by MessageLabs. For further information
visit http://www.mci.com
Thanks Ilya,
Everything is blindingly clear now!
Thanks for your response,
muchly appreciated
Steven
From: Ilya Makarov [mailto:makarov.tula@gmail.com]
Sent: Friday, 15 February 2013 2:50 PM
To: Katona, Steve
Cc: <pgadmin-support@postgresql.org>
Subject: Re: [pgadmin-support] ERROR: relative path not allowed for COPY to file
Hi. Is this path(”C:/Dev/test.csv") on the server with PostgreSQL database? You can't COPY to file on the client machine.
Part from man pages (http://www.postgresql.org/docs/9.1/static/sql-copy.html):
Files named in a COPY command are read or written directly by the server, not by the client application. Therefore, they must reside on or be accessible to the database server machine, not the client. They must be accessible to and readable or writable by the PostgreSQL user (the user ID the server runs as), not the client. COPY naming a file is only allowed to database superusers, since it allows reading or writing any file that the server has privileges to access.
Best regards,
Ilya Makarov
15.02.2013, в 6:43, "Katona, Steve" <SKatona@begavalley.nsw.gov.au> написал(а):
I am using pgAdmin 14.1 and then tried with pgAdmin 16.1
I have tried:
COPY (select * from file) TO '”C:/Dev/test.csv”';
And get the error:
ERROR: relative path not allowed for COPY to file
SQL state: 42602
Also, when I try:
COPY temp_import FROM E'"C:/Dev/exponare_data_mgr/exponare_filelist.txt"';
I get the following error:
ERROR: could not open file ""C:/Dev/exponare_data_mgr/exponare_filelist.txt"" for reading: No such file or directory
SQL state: 58P01
I suspect that pgAdmin is not passing the filename in a manner, that the shell on windows7 ,interprets correctly.
I have also tried the same commands from the psql console and achieve the same results.
Under linux the commands work well.
Is there a suggestion for things I change/check to get COPY to work?
Cheers
Steven
Check out all the latest news and events at Council on www.begavalley.nsw.gov.au.
_____________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed
Scanning Services - powered by MessageLabs. For further information
visit http://www.mci.com
_____________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed
Scanning Services - powered by MessageLabs. For further information
visit http://www.mci.com
_____________________________________________________________________
This e-mail has been scanned for viruses by MCI's Internet Managed
Scanning Services - powered by MessageLabs. For further information
visit http://www.mci.com