Re: COPY command and required file permissions

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: "bruno(dot)scovoli" <bruno(dot)scovoli(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: COPY command and required file permissions
Date: 2010-06-25 18:37:25
Message-ID: 4C24F765.40008@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 06/23/2010 02:01 PM, bruno.scovoli wrote:
>
> I have an script with many "\copy" commands. For example:
>
> \copy privilegios from '/work/eclipse-workspace/Canoan
> Server/database/load/privilegios.dat'
> \copy privilegios_de_usuarios from '/work/eclipse-workspace/Canoan
> Server/database/load/privilegios_de_usuarios.dat'
> \copy classificacoes from '/work/eclipse-workspace/Canoan
> Server/database/load/classificacoes.dat'
> \copy tipo_de_produto from '/work/eclipse-workspace/Canoan
> Server/database/load/tipos.dat'
>
> This lines are OK. But when I remove the preceding backslash from them I get
> the error that you mentioned.
>
>
> Harold A. Giménez Ch. wrote:
>>
>> Hi all,
>> In migrating an application from sql server to Postgres, I created a ruby
>> script that extracts csv files from sql server (from a windows box), then
>> SCPs them into a directory (/home/ruby_process) on the server running
>> Postgres (a Fedora core 8) and finally runs the Postgres COPY command for
>> each of the csv files.
>>
>> When the script runs the COPY commnand, I get the following error (for the
>> genders table):
>>
>> ERROR C42501 M could not open file "/home/ruby_process/genders.csv"
>> for
>> reading: Permission denied Fcopy.c L1694 RCopyFrom (RuntimeError)
>>
>> My question is, what are the set of permissions required to perform a
>> postgres copy?
>>
>> I've set the permissions on the directory so that the postgres group owns
>> the directory and has read and execute permissions, as follows:
>> drwxrwxr-x 3 ruby_process postgres
>>
>> I have also tried moving the files to /tmp and performing the copy from
>> there, unsuccesfuly.
>>
>> Any ideas would be appreciated. Thanks,
>> -Harold
>>
>>
>

Are you connecting to the database as a superuser to run the COPY command?

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tim Landscheidt 2010-06-25 19:01:14 Re: enforcing constraints across multiple tables
Previous Message Andrew Geery 2010-06-25 17:52:40 enforcing constraints across multiple tables