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 <[email protected] > 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 >
