summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql/client.py
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2020-12-23 23:39:43 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-01-20 17:30:37 +0100
commitdcb3ad3319cad5c270a1856fd5f355e37cf9d474 (patch)
tree919ded9b849cb0a4ae66052c030f5bfb2e980d1a /django/db/backends/postgresql/client.py
parentf054468cac325e8d8fa4d5934b939b93242a3730 (diff)
downloaddjango-dcb3ad3319cad5c270a1856fd5f355e37cf9d474.tar.gz
Fixed #32292 -- Added support for connection by service name to PostgreSQL.
Diffstat (limited to 'django/db/backends/postgresql/client.py')
-rw-r--r--django/db/backends/postgresql/client.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/django/db/backends/postgresql/client.py b/django/db/backends/postgresql/client.py
index 7965401163..2339880967 100644
--- a/django/db/backends/postgresql/client.py
+++ b/django/db/backends/postgresql/client.py
@@ -16,6 +16,7 @@ class DatabaseClient(BaseDatabaseClient):
dbname = settings_dict.get('NAME') or 'postgres'
user = settings_dict.get('USER')
passwd = settings_dict.get('PASSWORD')
+ service = options.get('service')
sslmode = options.get('sslmode')
sslrootcert = options.get('sslrootcert')
sslcert = options.get('sslcert')
@@ -33,6 +34,8 @@ class DatabaseClient(BaseDatabaseClient):
env = {}
if passwd:
env['PGPASSWORD'] = str(passwd)
+ if service:
+ env['PGSERVICE'] = str(service)
if sslmode:
env['PGSSLMODE'] = str(sslmode)
if sslrootcert: