summaryrefslogtreecommitdiff
path: root/django/db/backends/postgresql/client.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/backends/postgresql/client.py')
-rw-r--r--django/db/backends/postgresql/client.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/django/db/backends/postgresql/client.py b/django/db/backends/postgresql/client.py
index 2339880967..873af8cc14 100644
--- a/django/db/backends/postgresql/client.py
+++ b/django/db/backends/postgresql/client.py
@@ -13,7 +13,7 @@ class DatabaseClient(BaseDatabaseClient):
host = settings_dict.get('HOST')
port = settings_dict.get('PORT')
- dbname = settings_dict.get('NAME') or 'postgres'
+ dbname = settings_dict.get('NAME')
user = settings_dict.get('USER')
passwd = settings_dict.get('PASSWORD')
service = options.get('service')
@@ -22,13 +22,17 @@ class DatabaseClient(BaseDatabaseClient):
sslcert = options.get('sslcert')
sslkey = options.get('sslkey')
+ if not dbname and not service:
+ # Connect to the default 'postgres' db.
+ dbname = 'postgres'
if user:
args += ['-U', user]
if host:
args += ['-h', host]
if port:
args += ['-p', str(port)]
- args += [dbname]
+ if dbname:
+ args += [dbname]
args.extend(parameters)
env = {}