`must be superuser to COPY to or from a file' - using perl DBI - approaches to work around this

From: Dan Kortschak <dan(dot)kortschak(at)adelaide(dot)edu(dot)au>
To: pgsql-general(at)postgresql(dot)org
Subject: `must be superuser to COPY to or from a file' - using perl DBI - approaches to work around this
Date: 2009-10-13 00:14:59
Message-ID: 1255392899.3427.10.camel@zoidberg.mbs.adelaide.edu.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I'm using the perl DBI module to interface with Pg, generating a number
of tables and then loading them into a postgres database (this is to
automate a previously psql-based setup).

One instance of loading the data looks like this, but I am only able to
do this as a superuser (this is possible for me, but I would like to
avoid it):

$dbh->do("COPY chromosome_data FROM '".chromosomes(\%options)."' CSV");

Now either I can call psql from perl (missing the point of using DBI), I
can make the user a superuser (which I would like to avoid for safety
reasons) or I can try to figure out some way of IPC to get STDOUT from
the perl to be read into postgres via STDIN (this seems unnecessarily
complicated).

Does anyone have any suggestions (the least bad of the options above
seems to be to use psql, but I think that is ugly)?

Also, can anyone suggest why it is possible to create a database but not
COPY to/from a file as a non-superuser?

thanks
Dan

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Frost 2009-10-13 00:21:06 Re: `must be superuser to COPY to or from a file' - using perl DBI - approaches to work around this
Previous Message Alvaro Herrera 2009-10-13 00:08:19 Re: Nested transactions