Ticket #6710: psycopg2_connection_params.diff

File psycopg2_connection_params.diff, 1.7 KB (added by Robert Coup, 17 years ago)
  • django/db/backends/postgresql_psycopg2/base.py

     
    5757            if settings.DATABASE_NAME == '':
    5858                from django.core.exceptions import ImproperlyConfigured
    5959                raise ImproperlyConfigured("You need to specify DATABASE_NAME in your Django settings file.")
    60             conn_string = "dbname=%s" % settings.DATABASE_NAME
     60            conn_params = {
     61                'database': settings.DATABASE_NAME,
     62            }
     63            conn_params.update(self.options)
    6164            if settings.DATABASE_USER:
    62                 conn_string = "user=%s %s" % (settings.DATABASE_USER, conn_string)
     65                conn_params['user'] = settings.DATABASE_USER
    6366            if settings.DATABASE_PASSWORD:
    64                 conn_string += " password='%s'" % settings.DATABASE_PASSWORD
     67                conn_params['password'] = settings.DATABASE_PASSWORD
    6568            if settings.DATABASE_HOST:
    66                 conn_string += " host=%s" % settings.DATABASE_HOST
     69                conn_params['host'] = settings.DATABASE_HOST
    6770            if settings.DATABASE_PORT:
    68                 conn_string += " port=%s" % settings.DATABASE_PORT
    69             self.connection = Database.connect(conn_string, **self.options)
     71                conn_params['port'] = settings.DATABASE_PORT
     72            self.connection = Database.connect(**conn_params)
    7073            self.connection.set_isolation_level(1) # make transactions transparent to all cursors
    7174            self.connection.set_client_encoding('UTF8')
    7275        cursor = self.connection.cursor()
Back to Top