Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.0.X] Fixed #6710 -- Made DATABASE_OPTIONS work with postgresql_psy…

…copg2 backend.

Thanks to rcoup for the patch.

Backport of r9981 from trunk.

git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9982 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit dd5300274f81e8ea41f3ef41487179e2b1770d65 1 parent 31e059c
Malcolm Tredinnick authored March 06, 2009
1  AUTHORS
@@ -93,6 +93,7 @@ answer newbie questions, and generally made Django that much better:
93 93
     colin@owlfish.com
94 94
     crankycoder@gmail.com
95 95
     Paul Collier <paul@paul-collier.com>
  96
+    Robert Coup
96 97
     Pete Crosier <pete.crosier@gmail.com>
97 98
     Matt Croydon <http://www.postneo.com/>
98 99
     Leah Culver <leah@pownce.com>
15  django/db/backends/postgresql_psycopg2/base.py
@@ -72,16 +72,19 @@ def _cursor(self, settings):
72 72
             if settings.DATABASE_NAME == '':
73 73
                 from django.core.exceptions import ImproperlyConfigured
74 74
                 raise ImproperlyConfigured("You need to specify DATABASE_NAME in your Django settings file.")
75  
-            conn_string = "dbname=%s" % settings.DATABASE_NAME
  75
+            conn_params = {
  76
+                'database': settings.DATABASE_NAME,
  77
+            }
  78
+            conn_params.update(self.options)
76 79
             if settings.DATABASE_USER:
77  
-                conn_string = "user=%s %s" % (settings.DATABASE_USER, conn_string)
  80
+                conn_params['user'] = settings.DATABASE_USER
78 81
             if settings.DATABASE_PASSWORD:
79  
-                conn_string += " password='%s'" % settings.DATABASE_PASSWORD
  82
+                conn_params['password'] = settings.DATABASE_PASSWORD
80 83
             if settings.DATABASE_HOST:
81  
-                conn_string += " host=%s" % settings.DATABASE_HOST
  84
+                conn_params['host'] = settings.DATABASE_HOST
82 85
             if settings.DATABASE_PORT:
83  
-                conn_string += " port=%s" % settings.DATABASE_PORT
84  
-            self.connection = Database.connect(conn_string, **self.options)
  86
+                conn_params['port'] = settings.DATABASE_PORT
  87
+            self.connection = Database.connect(**conn_params)
85 88
             self.connection.set_isolation_level(1) # make transactions transparent to all cursors
86 89
             self.connection.set_client_encoding('UTF8')
87 90
         cursor = self.connection.cursor()

0 notes on commit dd53002

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