Can't get a simple COPY to work

Started by runnerabout 15 years ago3 messagesgeneral
Jump to latest
#1runner
runner@winning.com

I'm getting really frustrated, I can't get a simple COPY command to work. I've tried running psql and both the postgres user and the owner of the database with the same error.

psql -U postgres -d database1

database1=# BEGIN;
BEGIN
database1=# TRUNCATE TABLE grades;
TRUNCATE TABLE
database1=# COPY grades FROM grades_csv_file;
ERROR: syntax error at or near grades_csv_file

It won't let me enter the full path to the csv file and if I run psql from the directory where the csv file is located, it stilll won't accept the name of the csv file. So how do you specify the name of the csv file?

#2runner
runner@winning.com
In reply to: runner (#1)
Fwd: Can't get a simple COPY to work

I'm getting really frustrated, I can't get a simple COPY
command to work. I've tried running psql and both the
postgres user and the owner of the database with the same error.

Sorry about the, I see the file name requires a quote.

#3Adrian Klaver
adrian.klaver@aklaver.com
In reply to: runner (#1)
Re: Can't get a simple COPY to work

On Wednesday, March 16, 2011 2:36:25 pm runner wrote:

I'm getting really frustrated, I can't get a simple COPY command to work.
I've tried running psql and both the postgres user and the owner of the
database with the same error.

psql -U postgres -d database1

database1=# BEGIN;
BEGIN
database1=# TRUNCATE TABLE grades;
TRUNCATE TABLE
database1=# COPY grades FROM grades_csv_file;
ERROR: syntax error at or near grades_csv_file

It won't let me enter the full path to the csv file and if I run psql from
the directory where the csv file is located, it stilll won't accept the
name of the csv file. So how do you specify the name of the csv file?

COPY grades FROM 'grades_csv_file';
--
Adrian Klaver
adrian.klaver@gmail.com