hackoregon / emergency-response

Simulations, Models, and Visualizations of Portland Fire and Rescue data
11 stars 10 forks source link

Database permissions #58

Closed BrianHGrant closed 7 years ago

BrianHGrant commented 7 years ago

With user: eruser

api is getting:

permission denied for relation census_race

when inspecting the database and attempting to build updated models

russellgould commented 7 years ago

Running the query:

GRANT SELECT ON ALL TABLES IN SCHEMA public TO eruser;

within the fire db and with admin permissions should fix the issue. @sky-t or @kielejocain have those credentials.

kielejocain commented 7 years ago

I ran that as eradmin. @BrianHGrant , if it worked feel free to close. If not, let me know and I'll see what else I can do.

BrianHGrant commented 7 years ago

Thank you. Error is still occurring, though might be taking some time to refresh the system. @kielejocain, I will give some time and attempt again, will let you know if still failing.

Here is the stack trace though:

class CensusHousingTenure(models.Model):
    id = models.CharField(max_length=21)
    id2 = models.CharField(max_length=12)
    geography = models.CharField(max_length=60)
    estimate_total_households = models.IntegerField()
    estimate_total_owner_occupied = models.IntegerField()
    estimate_total_renter_occupied = models.IntegerField()

    class Meta:
        managed = False
        db_table = 'census_housing_tenure'

class CensusMedianHouseholdIncome(models.Model):
    id = models.CharField(max_length=21)
    id2 = models.CharField(max_length=12)
    geography = models.CharField(max_length=60)
    estimate_median_household_income = models.IntegerField()

    class Meta:
        managed = False
        db_table = 'census_median_household_income'

class CensusRace(models.Model):
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
psycopg2.ProgrammingError: permission denied for relation census_race

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.4/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.4/site-packages/django/core/management/__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.4/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.4/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.4/site-packages/django/core/management/commands/inspectdb.py", line 25, in handle
    for line in self.handle_inspection(options):
  File "/usr/local/lib/python3.4/site-packages/django/core/management/commands/inspectdb.py", line 75, in handle_inspection
    for row in connection.introspection.get_table_description(cursor, table_name):
  File "/usr/local/lib/python3.4/site-packages/django/db/backends/postgresql/introspection.py", line 77, in get_table_description
    cursor.execute("SELECT * FROM %s LIMIT 1" % self.connection.ops.quote_name(table_name))
  File "/usr/local/lib/python3.4/site-packages/django/db/backends/utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/usr/local/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python3.4/site-packages/django/db/utils.py", line 95, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python3.4/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.4/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
django.db.utils.ProgrammingError: permission denied for relation census_race
kielejocain commented 7 years ago

I tried running it again as eradmin, making sure I was in the fire.public schema. I then connected as eruser and queried select * from census_race limit 10 and got a response. Hopefully the issues is truly resolved now; if not, I suspect the cause may be something different.

BrianHGrant commented 7 years ago

I was able to successfully run. Closing issue. Thanks again @kielejocain and @russellgould.

sky-t commented 7 years ago

Sorry, my bad on this issue. I forgot to grant select all permissions after adding this particular table.