dbTalk Databases Forums  

COPY command cannot access file...

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss COPY command cannot access file... in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Alan T. Miller
 
Posts: n/a

Default COPY command cannot access file... - 01-29-2004 , 06:17 AM






I have an application that will only ever run locally on a development box.
The application writes a text file to the hard drive, and then issues the
"COPY" sql command to import records in that text file. The application ran
fine on one box, but then when trying to run it on another, I keep getting
error messages, something such as...

COPY command, running in backend with effective uid 501, could not open
file...

501 is the postgres user.

I understand why this is happening. The database server, does not seem to be
able to access the file and from what I understand changing permissions of
the file will not help. What I need to know is how can I give the database
server permission to read such files? I have a number of scripts written
this way that import millions of records. I read somewhere I should use the
'psql \copy' command instead. But then the manual page for the psql command
reccomends the SQL copy command for large numbers of records, and I would
hate to have to rewrite so many scripts to change it. With that, how can I
grant the database server what it needs to read these files.

Thanks in advance.
Alan



---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org


Reply With Quote
  #2  
Old   
HK
 
Posts: n/a

Default Re: COPY command cannot access file... - 01-29-2004 , 06:39 AM






Hi alan,
The problem is most likely to be in the permission for the directory.
Check if you have executable permission for all the directories before the
actual file for the 'postgres' user.

HTH.

Regards,
HK.

On Thu, 29 Jan 2004, Alan T. Miller wrote:

Quote:
I have an application that will only ever run locally on a development box.
The application writes a text file to the hard drive, and then issues the
"COPY" sql command to import records in that text file. The application ran
fine on one box, but then when trying to run it on another, I keep getting
error messages, something such as...

COPY command, running in backend with effective uid 501, could not open
file...

501 is the postgres user.

I understand why this is happening. The database server, does not seem to be
able to access the file and from what I understand changing permissions of
the file will not help. What I need to know is how can I give the database
server permission to read such files? I have a number of scripts written
this way that import millions of records. I read somewhere I should use the
'psql \copy' command instead. But then the manual page for the psql command
reccomends the SQL copy command for large numbers of records, and I would
hate to have to rewrite so many scripts to change it. With that, how can I
grant the database server what it needs to read these files.

Thanks in advance.
Alan



---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org



---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly



Reply With Quote
  #3  
Old   
Bruno Wolff III
 
Posts: n/a

Default Re: COPY command cannot access file... - 01-29-2004 , 07:14 AM



On Thu, Jan 29, 2004 at 05:17:23 -0700,
"Alan T. Miller" <amiller (AT) hollywood101 (DOT) com> wrote:
Quote:
I understand why this is happening. The database server, does not seem to be
able to access the file and from what I understand changing permissions of
the file will not help. What I need to know is how can I give the database
server permission to read such files? I have a number of scripts written
this way that import millions of records. I read somewhere I should use the
'psql \copy' command instead. But then the manual page for the psql command
reccomends the SQL copy command for large numbers of records, and I would
hate to have to rewrite so many scripts to change it. With that, how can I
grant the database server what it needs to read these files.
Normally you want to have the copy command read from standard input
and then the application can read from the file and write to the
connection.

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



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.