mirror of https://github.com/django/django.git
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
This commit is contained in:
parent
ce079538c6
commit
3c0ee70e7c
|
@ -18,8 +18,12 @@ class DatabaseWrapper:
|
|||
from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PASSWORD, DEBUG, TIME_ZONE
|
||||
if self.connection is None:
|
||||
# Note that "host=" has to be last, because it might be blank.
|
||||
self.connection = Database.connect("user=%s dbname=%s password=%s host=%s" % \
|
||||
(DATABASE_USER, DATABASE_NAME, DATABASE_PASSWORD, DATABASE_HOST))
|
||||
conn_string = "user=%s dbname=%s" % (DATABASE_USER, DATABASE_NAME)
|
||||
if DATABASE_PASSWORD:
|
||||
conn_string += " password=%s" % DATABASE_PASSWORD
|
||||
if DATABASE_HOST:
|
||||
conn_string += " host=%s" % DATABASE_HOST
|
||||
self.connection = Database.connect(conn_string)
|
||||
self.connection.set_isolation_level(1) # make transactions transparent to all cursors
|
||||
cursor = self.connection.cursor()
|
||||
cursor.execute("SET TIME ZONE %s", [TIME_ZONE])
|
||||
|
|
Loading…
Reference in New Issue