Django 5.1 + PostgreSQL (Debian Server)Python

Python-Programme
Anonymous
 Django 5.1 + PostgreSQL (Debian Server)

Post by Anonymous »

Versuchen Sie, eine Verbindung zur Postgresql-Basis herzustellen, wie Django in seinen Dokumenten geschrieben wurde:
https://docs.djangoproject.com/en/5.1/r ... esql-notes

Code: Select all

DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"OPTIONS": {
"service": "my_service",
"passfile": ".my_pgpass",
},
}
}

< /code>
Ich habe 2 Dateien in meinem Home -Verzeichnis erstellt
[b].pg_service.conf[/b]
[my_service]
host=/var/run/postgresql
user=dbms
dbname=dbms_db
port=5432
.pgpass
/var/run/postgresql:5432:dbms_db:dbms:my_password
< /code>
Befehl wie test von .pgpass: < /p>

PSQL -H localhost -u dbms dbms_db < /p> < Br /> < /blockquote>
funktioniert.
Aber die Verbindung funktioniert nicht: < /p>
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"OPTIONS": {
"service": "my_service",
"passfile": ".pgpass",
},
}
}
< /code>
mit einem solchen Fehler < /p>

Traceback (letztes Anruf letztes): Datei
" /home /www /Projects/amodulesu/venv/lib/python3.11/site-packages/django/db/backends/base/base.py",ell/> Zeile 279, in der Datei sicherer_connection
self.connect () "" /home/www/projects/amodulesu/venv/lib/python3.11/site-packages/django/utils/asyncio.py",
Zeile 26, in Inner
return func ( *args, * *kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /django/db/backends/base/base.py" ,
Zeile 256, in Connect
self.connection = self.get_new_connection (conn_params)
^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ django /utils /asyncio.py ",
Zeile 26, in Inner
return func (*args, ** kwargs)
^^^^^^^^^^^^ ^^^^^^^^ Datei "/home/www/projects/amodulesu/venv/lib/python3.11/site-packages/django/db/backends/postgresql/base.py",ell/> Zeile 332, In get_new_connection
Connection = self.database.connect (** conn_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^ Datei "/home/www/projcejects/amodulesu/venv/lib/python3.11/site-packages/psycopg/connection.py",ell/> Zeile 119, in Connect
Raise last_ex.with_traceback (keine) psycopg.operationalError: Verbindung fehlgeschlagen Für Benutzer "DBMS" ... Datei
"/home/www/projects/amodulesu/venv/lib/python3.11/site-packages/psycopg/connection.py",ell/> Zeile 119, in Connect
raise last_ex.with_traceback (keine) django.db.utils.operationalError: Verbindung fehlgeschlagen: Verbindung zu
Server auf Socket "/var/run/postgresql/.s.pgsql.5432" fehlgeschlagen: Fatal: Fatal: Fatal: Fatal: Fatal :
Peer -Authentifizierung für Benutzer "DBMS" < /p>
< /blockquote>
Was ist mit meinem Code los? Um Exportvars in Debian zu verwenden - funktioniert es aber nicht auch. jt5czgjf.png " /> < /p>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post