pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: COPY command and required file permissions
3+ messages / 2 participants
[nested] [flat]
* Re: COPY command and required file permissions
@ 2010-06-23 21:01 bruno.scovoli <bruno.scovoli@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: bruno.scovoli @ 2010-06-23 21:01 UTC (permalink / raw)
To: pgsql-sql
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
>
>
--
View this message in context: http://old.nabble.com/COPY-command-and-required-file-permissions-tp17800484p28976565.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: COPY command and required file permissions
@ 2010-06-25 18:37 Adrian Klaver <adrian.klaver@gmail.com>
parent: bruno.scovoli <bruno.scovoli@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Adrian Klaver @ 2010-06-25 18:37 UTC (permalink / raw)
To: bruno.scovoli <bruno.scovoli@gmail.com>; +Cc: 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.klaver@gmail.com
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: COPY command and required file permissions
@ 2010-06-26 01:51 Adrian Klaver <adrian.klaver@gmail.com>
parent: Adrian Klaver <adrian.klaver@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Adrian Klaver @ 2010-06-26 01:51 UTC (permalink / raw)
To: Bruno Scovoli Santos <bruno.scovoli@gmail.com>; +Cc: pgsql-sql
On Friday 25 June 2010 6:07:35 pm Bruno Scovoli Santos wrote:
> * Are you connecting to the database as a superuser to run the COPY
> command? *
>
> Yes. This \copy command is in the database build script (create table
> blablabla....). So it almost (I think) must have to be a superuser.
>
> But hey, my intent was just to guide the guy (Harold A. Giménez Ch.) to
> follow my practice (to use a preceding backslash). I dont bother to have to
> add that preceding backslash in my script. ;-)
>
>
Actually my question was directed to Harold, I put my reply in the wrong place.
In any case COPY and \copy are different commands. COPY is done from the
server's perspective, \copy from the clients. Hence the permission issues will
be different. See below for more detail.
http://www.postgresql.org/docs/8.4/interactive/sql-copy.html
http://www.postgresql.org/docs/8.4/interactive/app-psql.html
--
Adrian Klaver
adrian.klaver@gmail.com
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2010-06-26 01:51 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-06-23 21:01 Re: COPY command and required file permissions bruno.scovoli <bruno.scovoli@gmail.com>
2010-06-25 18:37 ` Adrian Klaver <adrian.klaver@gmail.com>
2010-06-26 01:51 ` Adrian Klaver <adrian.klaver@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox