Fixed #6710 -- Made DATABASE_OPTIONS work with postgresql_psycopg2 backend.
Thanks to rcoup for the patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9981 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
923f78f504
commit
b5d4a8ae1b
1
AUTHORS
1
AUTHORS
|
@ -97,6 +97,7 @@ answer newbie questions, and generally made Django that much better:
|
||||||
colin@owlfish.com
|
colin@owlfish.com
|
||||||
crankycoder@gmail.com
|
crankycoder@gmail.com
|
||||||
Paul Collier <paul@paul-collier.com>
|
Paul Collier <paul@paul-collier.com>
|
||||||
|
Robert Coup
|
||||||
Pete Crosier <pete.crosier@gmail.com>
|
Pete Crosier <pete.crosier@gmail.com>
|
||||||
Matt Croydon <http://www.postneo.com/>
|
Matt Croydon <http://www.postneo.com/>
|
||||||
Leah Culver <leah@pownce.com>
|
Leah Culver <leah@pownce.com>
|
||||||
|
|
|
@ -72,16 +72,19 @@ class DatabaseWrapper(BaseDatabaseWrapper):
|
||||||
if settings.DATABASE_NAME == '':
|
if settings.DATABASE_NAME == '':
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
raise ImproperlyConfigured("You need to specify DATABASE_NAME in your Django settings file.")
|
raise ImproperlyConfigured("You need to specify DATABASE_NAME in your Django settings file.")
|
||||||
conn_string = "dbname=%s" % settings.DATABASE_NAME
|
conn_params = {
|
||||||
|
'database': settings.DATABASE_NAME,
|
||||||
|
}
|
||||||
|
conn_params.update(self.options)
|
||||||
if settings.DATABASE_USER:
|
if settings.DATABASE_USER:
|
||||||
conn_string = "user=%s %s" % (settings.DATABASE_USER, conn_string)
|
conn_params['user'] = settings.DATABASE_USER
|
||||||
if settings.DATABASE_PASSWORD:
|
if settings.DATABASE_PASSWORD:
|
||||||
conn_string += " password='%s'" % settings.DATABASE_PASSWORD
|
conn_params['password'] = settings.DATABASE_PASSWORD
|
||||||
if settings.DATABASE_HOST:
|
if settings.DATABASE_HOST:
|
||||||
conn_string += " host=%s" % settings.DATABASE_HOST
|
conn_params['host'] = settings.DATABASE_HOST
|
||||||
if settings.DATABASE_PORT:
|
if settings.DATABASE_PORT:
|
||||||
conn_string += " port=%s" % settings.DATABASE_PORT
|
conn_params['port'] = settings.DATABASE_PORT
|
||||||
self.connection = Database.connect(conn_string, **self.options)
|
self.connection = Database.connect(**conn_params)
|
||||||
self.connection.set_isolation_level(1) # make transactions transparent to all cursors
|
self.connection.set_isolation_level(1) # make transactions transparent to all cursors
|
||||||
self.connection.set_client_encoding('UTF8')
|
self.connection.set_client_encoding('UTF8')
|
||||||
cursor = self.connection.cursor()
|
cursor = self.connection.cursor()
|
||||||
|
|
Loading…
Reference in New Issue