Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django.db.utils.ProgrammingError: must be superuser to COPY to or from a file #22

Open
greglinch opened this issue Feb 12, 2016 · 5 comments
Labels

Comments

@greglinch
Copy link

Hello! I've run into a perms error, which blocks my script from executing the copy in a Django management:

django.db.utils.ProgrammingError: must be superuser to COPY to or from a file

I'm running:

  • OS 10.10.5
  • Python 2.7.4
  • Django 1.9
  • current version of django-postgres-copy

Thanks!

$ ./manage.py <my_management_command>

Loading <file>.csv.

Loading CSV to <model>
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/<my>/<path>/.virtualenvs/mccelections/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
    utility.execute()
  File "/<my>/<path>/.virtualenvs/mccelections/lib/python2.7/site-packages/django/core/management/__init__.py", line 342, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/<my>/<path>/.virtualenvs/mccelections/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/<my>/<path>/.virtualenvs/mccelections/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/<my>/<path>/<to>/<dir>/<djangoproject>/<djangoapp>/management/commands/<my_management_command>", line 57, in handle
    c.save()
  File "/<my>/<path>/.virtualenvs/mccelections/lib/python2.7/site-packages/postgres_copy/__init__.py", line 86, in save
    cursor.execute(copy_sql)
  File "/<my>/<path>/.virtualenvs/mccelections/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/<my>/<path>/.virtualenvs/mccelections/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/<my>/<path>/.virtualenvs/mccelections/lib/python2.7/site-packages/django/db/utils.py", line 95, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/<my>/<path>/.virtualenvs/mccelections/lib/python2.7/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
django.db.utils.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.
@palewire
Copy link
Owner

I haven't run into this before, but my gut is to guess it's a lower-level permissions issue with either your postgres user, or your system user. Have you worked through suggestions like this?

@greglinch
Copy link
Author

@palewire Yeah, that was one of the threads I came across. I'll check it out again, thanks!

@greglinch greglinch reopened this Mar 10, 2016
@greglinch
Copy link
Author

I haven't had a chance to investigate further or try possible fixes, but re-opening and copying @merbroussard, who had a similar issue.

@merbroussard
Copy link

I got the same error. I managed to make it work by doing sudo python manage.py [commandnamehere]. Eager to discover the underlying cause.

@palewire
Copy link
Owner

palewire commented Apr 1, 2018

Is this still an error for you guys?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants