473,396 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem with sql COPY command

Hi,

I'm trying to do a simple import of a comma delimited text file with COPY
but it's returning an error. The file has been granted all permissions in
Linux, so it's not clear to me what the problem is. Version 7.41 is
installed... see below for details:

A comma delimited text file has been placed in a local directory with
permissions set to allow any user to read or write to it:
/root/Desktop/server_transfer/WorldPoints_v2.txt'
I'm trying to use the COPY command to import this text file into a table
from the PSQL command prompt.
First, open PSQL with parameters to open the right db: psql my_database -h
xxxx -U xxx
To import this file from the PSQL command line, call the COPY command:
copy public.world_stopwatch_v2 FROM
'/root/Desktop/server_transfer/WorldPoints_v2.txt' using delimiters ',';
COPY fails with this error message:
could not open file "/root/Desktop/server_transfer/WorldPoints_v2.txt" for
reading: Permission denied
(Database checked- it contains a table called: public.world_stopwatch_v2)

Thanks, Jon


Nov 23 '05 #1
4 7001
"Jon Asher" <jo*@vagabond-software.com> writes:
A comma delimited text file has been placed in a local directory with
permissions set to allow any user to read or write to it:
/root/Desktop/server_transfer/WorldPoints_v2.txt'


The '/root' directory is often not world-readable. Try putting the
file under '/tmp' or '/var/tmp', and remember that the file will be
read as the "postgres" user (or whatever your database server runs
as).

-Doug
--
Let us cross over the river, and rest under the shade of the trees.
--T. J. Jackson, 1863

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #2
On Fri, Aug 27, 2004 at 03:03:34PM -0700, Jon Asher wrote:
COPY fails with this error message:
could not open file "/root/Desktop/server_transfer/WorldPoints_v2.txt" for
reading: Permission denied


Don't forget that you'll need to set permissions on all the intermediate
directories as well as the file itself. It is probably safer to put the
file somewhere else than to make /root world-accessible. /tmp or an
ordinary user's home directory would be possibilities.
Richard

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #3
Hi,

Am Sa, den 28.08.2004 schrieb Jon Asher um 0:03:
Hi,

I'm trying to do a simple import of a comma delimited text file with
COPY but it's returning an error. The file has been granted all
permissions in Linux, so it's not clear to me what the problem is.
Version 7.41 is installed... see below for details:

A comma delimited text file has been placed in a local directory with
permissions set to allow any user to read or write to it:
/root/Desktop/server_transfer/WorldPoints_v2.txt'

I'm trying to use the COPY command to import this text file into a
table from the PSQL command prompt.

First, open PSQL with parameters to open the right db: psql
my_database -h xxxx -U xxx

To import this file from the PSQL command line, call the COPY command:
copy public.world_stopwatch_v2 FROM
'/root/Desktop/server_transfer/WorldPoints_v2.txt' using delimiters
',';

COPY fails with this error message:
could not open file "/root/Desktop/server_transfer/WorldPoints_v2.txt"
for reading: Permission denied

(Database checked- it contains a table called:
public.world_stopwatch_v2)


*wild guessing* Is desktop and server the same
machine? If not, you cannot use the copy command
that way. If you issue a copy command with a path
to a file, the backand on the server has to find
the file. If its on your desktop, this operation
will not succeed.

Either you copy your file to the server in that case
or use copy from stdin with psql.

HTH
Tino Wildenhain
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #4
Thanks to all... it's importing now. I'm still learning Linux after
upgrading from Windows. Moving the file to another dir (\tmp) did it. Jon

-----Original Message-----
From: pg*****************@postgresql.org
[mailto:pg*****************@postgresql.org] On Behalf Of Richard Poole
Sent: Friday, August 27, 2004 3:16 PM
To: pg***********@postgresql.org
Subject: Re: [GENERAL] Problem with sql COPY command

On Fri, Aug 27, 2004 at 03:03:34PM -0700, Jon Asher wrote:
COPY fails with this error message:
could not open file "/root/Desktop/server_transfer/WorldPoints_v2.txt"
for
reading: Permission denied


Don't forget that you'll need to set permissions on all the intermediate
directories as well as the file itself. It is probably safer to put the file
somewhere else than to make /root world-accessible. /tmp or an ordinary
user's home directory would be possibilities.
Richard

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: WKC | last post by:
Hi guys, I really have a strange problem that I have no where to look for answer. I have a DTS that generate a text file with data queries from sql server 2K then stores it in a local drive. The...
0
by: Wind Wood | last post by:
Hello £¡ I can dump data from old dababase(Postgresql 6.5.3), but new problem came out when I restore the data to postgresql 7.4. It went out during the COPY command, if I do it in such command...
2
by: Chris Bolus | last post by:
I'm a teacher using MS Access on an RMConnect 2.4 network. On some workstations both I and my students sometimes get an error message when attempting to insert a command button on a form which...
15
by: Ken Allen | last post by:
I have been developing a suite of assemblies over the past couple of weeks, and this afternoon somethign started misbehaving. If I do not run the IDE and compiler the code from the command line,...
3
by: Eugene | last post by:
I'm trying to write a class which uses BinaryWriter as its base but allows for queuing of write requests Public Class QueuedBinaryWriter Inherits BinaryWriter I override all the Write methods...
1
by: Knepper, Michelle | last post by:
Hi out there, I'm a first-time user of the "Copy ... From..." command, and I'm trying to load a table from a text flat file. http://www.postgresql.org/docs/7.4/static/sql-copy.html I don't...
1
by: Rachel McConnell | last post by:
Hi, I am trying to import data using COPY, from a file containing thirty or so COPY commands each with 0 or more rows of data. Reason, I have a small data set I want to include into a database...
3
by: Marcel | last post by:
Hello, I have a problem with accessing files on other computers in my network. The network is a Windows 2000 workgroup network and I have administrator rights.... This works (from the directory...
5
by: akshaycjoshi | last post by:
I am developign one application where i copy one file to other location using System.Diagnostics.Process.Start In developement the command is just running fine . The command is /c copy ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.