PostgreSQL import CSV File causes Syntax Error
\copy
is a psql (commandline) command. It is not a regular SQL command.
You will need to use COPY instead (but that requires the file to be present on the database server)
Please refer to the postgres manual for COPY.
In pgAdmin (or the sql string you pass via a script or other db connection) you would just use COPY with no "\" prefix.
so enter something like :
COPY tablename....
You need to make sure that you have the relevant privileges to run the command, so in this case you need to be able to log into the database and have write access to 'tablename'. Postgres also needs to be able to reach the file, so the path /home/uploads/ should be accessible on the database server and the postgres user should be able to read the file - check the permissions to the file and directory.
On my 9.1 system the error I get is quite informative:
or_examples=> copy comp_table_test from '/tmp/test';
ERROR: must be superuser to COPY to or from a file
HINT: Anyone can COPY to stdout or from stdin. psql's \copy command also works for anyone.
If you read the hint again carefully it notes you can copy from stdin. This is what \copy in psql actually does in the back-end. See the docs at http://www.postgresql.org/docs/8.3/static/sql-copy.html for more information.
You could then put the body of the copy into your query or at least that's how it works in psql.