473,602 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_st opwatch_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_st opwatch_v2)

Thanks, Jon


Nov 23 '05 #1
4 7018
"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 YourEmailAddres sHere" to ma*******@postg resql.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_st opwatch_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_st opwatch_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****** ***********@pos tgresql.org] On Behalf Of Richard Poole
Sent: Friday, August 27, 2004 3:16 PM
To: pg***********@p ostgresql.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*******@postg resql.org

Nov 23 '05 #5

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

Similar topics

2
5824
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 last step of that DTS is to copy that file to a network drive using a batch file called by the Process Task. The commands in the batch file is basically create a network drive, copies the file over, then delete the source. The file gets copy...
0
1435
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 lines: 1. pg_dump news -f pgsql-database-news.sql #in old system with postgresql 6.5.3 2. su - postgres #in new system with postgresql 7.4 3. createdb -T template0 news 4. psql news < pgsql-database-news.sql ------
2
9282
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 reads "Invalid use of null". The remainder of the options in the Command Button Wizard are then unavailable and the button wil not work. The only solution is to log on to a different workstation. Any ideas?
15
2416
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, the compilation seems to work properly almost all of the time. More on this later. If I launch one copy of the IDE, then I can usually compile the project at least once. At some point, the build fails reporting "Could not copy temporary files...
3
1795
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 like so: Public Overloads Overrides Sub Write(ByVal Value As Byte) m_Queue.Enqueue(New WriteRequest(MyBase.BaseStream.Position, Value)) End Sub 'same for all other Write variants
1
5589
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 know if I'm using the command correctly. Question: I run this command as a superuser, and the "copy from" command is run like a SQL command on the command line, correct?
1
3530
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 with an identical schema, with existing data. I figured a good way to do this would be to use pg_dump on the small dataset, trim out the table definitions and constraints, and run the resulting file. (I also reordered the COPY statements to...
3
2907
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 copytest I copy something to copytest2): <?php copy('05_17340.jpg', 'D:\\copytest2\\test.jpg'); ?>
5
1134
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 C:\app\mainstructure.mdb C:\traffic\trafficmanagement\trafficmanagement\bin\Debug /c rename C:\traffic\trafficmanagement\trafficmanagement\bin\Debug\mainstructure.mdb 1999fine.mdb
0
7993
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7920
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8268
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6730
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5440
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3900
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1254
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.