airflow-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laura Lorenz <llor...@industrydive.com>
Subject Re: Logging to postgres as super user
Date Thu, 03 Nov 2016 15:40:45 GMT
You'll need to call your task with a postgres connection that authenticates
as a user that already has the privileges (e.g. superuser privileges) it
needs. You can change the connection details for a database connection
either airflow-wide by changing the default connection through the UI
<https://airflow.incubator.apache.org/configuration.html#connections> or
with an environment variable, or pass a non-default connection through to
the specific task's operator
<https://airflow.incubator.apache.org/code.html#airflow.operators.PostgresOperator>,
or if you instantiate the hook yourself, the hook's get_connection method
<https://github.com/apache/incubator-airflow/blob/master/airflow/hooks/base_hook.py#L59>.
You'd need to already have the credentials to an appropriately provisioned
postgres user; otherwise you'll need to create or modify a user with the
appropriate privileges on your postgres server directly in the first place.

On Wed, Nov 2, 2016 at 7:31 AM, twinkle sachdeva <twinkle.sachdeva@gmail.com
> wrote:

> Hi,
>
> I was trying to do bulk upload via postgres using it's copy command.
>
> While doing so, i received message :
>
> airflow/hooks/postgres_hook.py", line 58, in bulk_load
>
>     cur.execute("COPY %s FROM '%s'" % (table, tmp_file))
>
> psycopg2.ProgrammingError: 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.
>
> While browsing, i got to know that i can use alter user command, to assign
> superuser status to the current user.
>
> While trying to execute that, i am receiving following error :
>
> cur.execute("alter user smrt_repl_rt superuser;")
>
> psycopg2.ProgrammingError: must be superuser to alter superusers
>
>
> Is there a way, i can connect to database as super user via some other
> arguments?
>
>
> Regards,
>
> Twinkle
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message