django-postgres-copy
django-postgres-copy copied to clipboard
django.db.utils.ProgrammingError: must be superuser to COPY to or from a file
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.
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?
@palewire Yeah, that was one of the threads I came across. I'll check it out again, thanks!
I haven't had a chance to investigate further or try possible fixes, but re-opening and copying @merbroussard, who had a similar issue.
I got the same error. I managed to make it work by doing sudo python manage.py [commandnamehere]. Eager to discover the underlying cause.
Is this still an error for you guys?