From dcb3ad3319cad5c270a1856fd5f355e37cf9d474 Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Wed, 23 Dec 2020 23:39:43 +0100 Subject: Fixed #32292 -- Added support for connection by service name to PostgreSQL. --- docs/ref/databases.txt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'docs/ref') diff --git a/docs/ref/databases.txt b/docs/ref/databases.txt index a9edf43c54..b9a82140a0 100644 --- a/docs/ref/databases.txt +++ b/docs/ref/databases.txt @@ -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 ------------------------------------- -- cgit v1.3