Psycopg2.ErrorsPython

Python-Programme
Anonymous
 Psycopg2.Errors

Post by Anonymous »

Wie meine Einstellungen für DB aussehen: < /p>

Code: Select all

ALLOWED_HOSTS = ['*']

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'fishercoder',
'USER': 'fishercoderuser',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '5432',
}
}
< /code>

Ich habe einen neuen und leeren DB mit dem Namen "Fiscoder" auf diese Weise erstellt: < /p>

psql -U postgres
create database fishercoder;
ALTER USER postgres with password 'badpassword!';
CREATE USER fishercoderuser WITH PASSWORD 'password';
ALTER ROLE fishercoderuser SET client_encoding TO 'utf8';
ALTER ROLE fishercoderuser SET default_transaction_isolation TO 'read committed';
ALTER ROLE fishercoderuser SET timezone TO 'PST8PDT';
GRANT ALL PRIVILEGES ON DATABASE fishercoder TO fishercoderuser;

< /code>

Dann habe ich meinen anderen SQL -Dump erfolgreich in diesen neuen DB importiert, indem ich ausgeführt wurde:psql -U postgres fishercoder < fishercoder_dump.sql


Dann habe ich versucht, zu rennen.Traceback (most recent call last):
File "/home/ubuntu/myprojectdir/myprojectenv/lib/python3.6/site-packages/django/db/backends/utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.InsufficientPrivilege: permission denied for relation django_migrations
< /code>

Ich habe diese drei verwandten Beiträge auf SO:
Eins, zwei und drei < /p>

Ich habe die Befehle ausprobiert, die sie vorgeschlagen haben: < /p>

postgres=# GRANT ALL ON ALL TABLES IN SCHEMA public to fishercoderuser;
GRANT
postgres=# GRANT ALL ON ALL SEQUENCES IN SCHEMA public to fishercoderuser;
GRANT
postgres=# GRANT ALL ON ALL FUNCTIONS IN SCHEMA public to fishercoderuser;
GRANT
< /code>

Nein Glück, dann habe ich meinen postgresql DB neu gestartet: sudo service postgresql restart < /code>
, als ich versuchte, Migrationen erneut auszuführen, noch mit dem gleichen Fehler ausgesetzt.ubuntu@ip-xxx-xxx-xx-xx:~$ psql -U postgres
Password for user postgres:
psql (10.12 (Ubuntu 10.12-0ubuntu0.18.04.1))
Type "help" for help.

postgres=# \dt django_migrations
Did not find any relation named "django_migrations".
postgres=# \d django_migrations
Did not find any relation named "django_migrations".
postgres=# \dp django_migrations
Access privileges
Schema | Name | Type | Access privileges | Column privileges | Policies
--------+------+------+-------------------+-------------------+----------
(0 rows)

postgres=# SHOW search_path; \dt *.django_migrations
search_path
-----------------
"$user", public
(1 row)

Did not find any relation named "*.django_migrations".

postgres=# \dn+ public.
List of schemas
Name | Owner | Access privileges | Description
--------------------+----------+----------------------+----------------------------------
information_schema | postgres | postgres=UC/postgres+|
| | =U/postgres |
pg_catalog | postgres | postgres=UC/postgres+| system catalog schema
| | =U/postgres |
pg_temp_1 | postgres | |
pg_toast | postgres | | reserved schema for TOAST tables
pg_toast_temp_1 | postgres | |
public | postgres | postgres=UC/postgres+| standard public schema
| | =UC/postgres |
(6 rows)
< /code>

Irgendwelche Ideen, wie man das behebt? < /p>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post