Frustration with \copy

Started by Ralph Smithover 15 years ago3 messagesgeneral
Jump to latest
#1Ralph Smith
rsmith@10kinfo.com

As someone famous once said:

The documentation I've found on \copy says to see the docs on copy ;)

It's *supposed* to match the backend syntax, but seems a few bricks
shy of a load at the moment. Anyone feel like fixing it? See
parse_slash_copy() in src/bin/psql/copy.c.

That was a while ago, but it seems to still hold true.
I'm assuming it HAD to work (ca v7.4), if one just had the syntax laid out right.

I have a one column .txt file on Ubuntu that I'm trying to upload, and ....
\copy new_coupons '/home/rsmith/testfile.txt'
\copy: parse error at "'/home/rsmith/testfile"

I've looked for caveats (that I didn't expect to find) WRT the EOL delimiter.
I also apostrophed the text when it didn't need it.

In my very recent unemployed state I boned-up-on and did a little consulting on
Oracle and MySQL, and the others did work.
Now I remember why I had dark clouds associated with this command.

If I have to I can build a series of INSERT statements.

Yes, we are planning to upgrade to 8.3, but now I'm stuck w/ 7.4.
Should I just INSERT?

Thanks!
Ralph

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Ralph Smith (#1)
Re: Frustration with \copy

Ralph Smith <rsmith@10kinfo.com> writes:

I have a one column .txt file on Ubuntu that I'm trying to upload, and ....
\copy new_coupons '/home/rsmith/testfile.txt'

I think you need
\copy new_coupons from '...'

Like it says, it's supposed to match the backend syntax, modulo needing
a starting backslash and no ending semicolon.

regards, tom lane

#3David Fetter
david@fetter.org
In reply to: Ralph Smith (#1)
Re: Frustration with \copy

On Fri, Sep 10, 2010 at 10:25:52AM -0700, Ralph Smith wrote:

Yes, we are planning to upgrade to 8.3, but now I'm stuck w/ 7.4.

Don't stay stuck there too long. It's about to end its life, as are
8.0 and 8.1, later this year.

http://wiki.postgresql.org/wiki/PostgreSQL_Release_Support_Policy

Should I just INSERT?

Nope.

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate