in reply to Correct syntax for using \copy to import a file into a Postgres db

I'm not familiar with the syntax of Postgresql, but I think you just need to do something like this.
my $s2 = "\\copy (" ....
Or what you can do is to print $s2 and see if the syntax is valid in Postgresql.
  • Comment on Re: Correct syntax for using \copy to import a file into a Postgres db
  • Download Code

Replies are listed 'Best First'.
Re^2: Correct syntax for using \copy to import a file into a Postgres db
by BruceDB (Novice) on Nov 12, 2009 at 06:20 UTC

    thx,

    i tried \\c but that also wasn't working.

    your second idea was a good one. i printed $s2 and entered it directly into psql.

    that, however, revealed another issue:

    btest-> \copy (testingtable) FROM 'data.tsv' data.tsv: No such file or directory

    now i have to figure out what directory i'm in and what directory the file is in. according to some documentation, i should be able to get the first by entering in \!pwd, however, psql is telling me that is an invalid command.

      Hi did u fixed the error? If yes please suggest me with some hint. I'm facing the same error even when giving the correct file path