1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #32292 -- Added support for connection by service name to PostgreSQL.

This commit is contained in:
Hasan Ramezani
2020-12-23 23:39:43 +01:00
committed by Mariusz Felisiak
parent f054468cac
commit dcb3ad3319
6 changed files with 92 additions and 7 deletions

View File

@@ -108,11 +108,43 @@ required, though the latest release is recommended.
.. _psycopg2: https://www.psycopg.org/
.. _postgresql-connection-settings:
PostgreSQL connection settings
-------------------------------
See :setting:`HOST` for details.
To connect using a service name from the `connection service file`_, you must
specify it in the :setting:`OPTIONS` part of your database configuration in
:setting:`DATABASES`:
.. code-block:: python
:caption: settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'OPTIONS': {'service': 'my_service'},
}
}
.. code-block:: text
:caption: .pg_service.conf
[my_service]
host=localhost
user=USER
dbname=NAME
password=PASSWORD
port=5432
.. _connection service file: https://www.postgresql.org/docs/current/libpq-pgservice.html
.. versionchanged:: 4.0
Support for connecting by a service name was added.
Optimizing PostgreSQL's configuration
-------------------------------------