Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Changed db/backends/postgresql.py to add the password and host params…

… only if they're not blank

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 3c0ee70e7c6b9e40cef611061f7756c80691ee76 1 parent ce07953
Adrian Holovaty authored July 13, 2005

Showing 1 changed file with 6 additions and 2 deletions. Show diff stats Hide diff stats

  1. 8  django/core/db/backends/postgresql.py
8  django/core/db/backends/postgresql.py
@@ -18,8 +18,12 @@ def cursor(self):
18 18
         from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PASSWORD, DEBUG, TIME_ZONE
19 19
         if self.connection is None:
20 20
             # Note that "host=" has to be last, because it might be blank.
21  
-            self.connection = Database.connect("user=%s dbname=%s password=%s host=%s" % \
22  
-                (DATABASE_USER, DATABASE_NAME, DATABASE_PASSWORD, DATABASE_HOST))
  21
+            conn_string = "user=%s dbname=%s" % (DATABASE_USER, DATABASE_NAME)
  22
+            if DATABASE_PASSWORD:
  23
+                conn_string += " password=%s" % DATABASE_PASSWORD
  24
+            if DATABASE_HOST:
  25
+                conn_string += " host=%s" % DATABASE_HOST
  26
+            self.connection = Database.connect(conn_string)
23 27
             self.connection.set_isolation_level(1) # make transactions transparent to all cursors
24 28
         cursor = self.connection.cursor()
25 29
         cursor.execute("SET TIME ZONE %s", [TIME_ZONE])

0 notes on commit 3c0ee70

Please sign in to comment.
Something went wrong with that request. Please try again.