473,289 Members | 1,866 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,289 software developers and data experts.

using the "copy from" command to load tables from a txt flat file

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?
I get the following error. Any suggestions would be greatly
appreciated.

[mknepper@barney datafiles]$ psql -U postgres medispan
Welcome to psql 7.3.4, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit

medispan=# COPY mmw_ade_com FROM
'/home/mknepper/medispan/datafiles/mmwadecom.txt' WITH DELIMITER '|';
ERROR: COPY command, running in backend with effective uid 500, could
not open file '/home/mknepper/medispan/datafiles/mmwadecom.txt' for
reading. Errno = Permission denied (13).
medispan=#

Table schema:

CREATE TABLE mmw_ade_com
(
gpi VARCHAR(14) NOT NULL,
mcid INTEGER NOT NULL,
restrictionid INTEGER NOT NULL,
sequencenumber SMALLINT NOT NULL,
textid INTEGER,
PRIMARY KEY (gpi, mcid, restrictionid, sequencenumber)
);

example of data, from the TXT flat file, called mmwadecom.txt:

01100040100310|5|0|10|14608
01100040100310|8|0|10|17377
01100040100310|8|0|20|18061
01100040100310|8|0|30|14608
01100040100310|22|0|10|18025
01100040100310|30|0|10|14608
01100040100310|36|0|10|14608
01100040100310|115|0|10|13937
01100040100310|115|0|20|18041

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

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

Nov 23 '05 #1
1 5560
Knepper, Michelle wrote:
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?
I get the following error. Any suggestions would be greatly
appreciated.
The user you're logged in as doesn't matter to "copy from". It's
the user that the Postgres server is running as that is important.
[mknepper@barney datafiles]$ psql -U postgres medispan
Welcome to psql 7.3.4, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit

medispan=# COPY mmw_ade_com FROM
'/home/mknepper/medispan/datafiles/mmwadecom.txt' WITH DELIMITER '|';
ERROR: COPY command, running in backend with effective uid 500, could
not open file '/home/mknepper/medispan/datafiles/mmwadecom.txt' for
reading. Errno = Permission denied (13).


This error is pretty explicit. The server is running as UID 500, and
UID 500 doesn't have read access to the file in question. An easy
solution could be to get everyone read access to the file. If your
security concerns are high, you'll have to work out something better,
but your definately getting hung up on file permissions.

For future reference:
copy runs with the permissions of the server process.
\copy runs with the permissions of the client process.

--
Bill Moran
Potential Technologies
http://www.potentialtech.com
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 23 '05 #2

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

Similar topics

0
by: cbb | last post by:
I'm using ver. 7.4.6.1 from a generic install of Fedora Core 3. I always get "permission denied" error when using the COPY command to load to a table from a text file. I'm logged on to the db as...
4
by: oceanhai | last post by:
We currently have a PPTP connection set up for our developers to access our development SQL server through a VPN tunnel. When they need to copy tables up to the dev SQL from their local machine...
1
by: Deepa K | last post by:
Hi All, Is it possible to insert n rows with 1 or 2 invalid rows using copy command. I used it, it rollbacks everything even if 1 row gets an error. Is their any other way to do it. TIA --...
2
by: Don Isgitt | last post by:
Hi, I am recreating a database and its applications onto a new server and new software; old version of pg was 7.2.4 and new version is gds2=# select version(); version ...
2
by: Knepper, Michelle | last post by:
Hi, 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'm getting the...
4
by: Jon Asher | last post by:
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...
4
by: Kevin Murphy | last post by:
This is a tip for the record in case it helps somebody else in the future. I have an import script that relies on a stored procedure that runs as a trigger on inserts into a temporary table. ...
0
by: Robert Fitzpatrick | last post by:
I have a PHP script that was having problems using the COPY command with files around 1500 lines in size. The script will build the copy data from incoming CSV file into a temp file, then start a...
3
by: devinath | last post by:
I came across a problem while running the system file. When the copy command is run using system command , it doesn’t copy files which have size of 0kb. But the same command works if run thru the...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.