Ticket #6710: psycopg2_connection_params.diff
File psycopg2_connection_params.diff, 1.7 KB (added by , 17 years ago) |
---|
-
django/db/backends/postgresql_psycopg2/base.py
57 57 if settings.DATABASE_NAME == '': 58 58 from django.core.exceptions import ImproperlyConfigured 59 59 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) 61 64 if settings.DATABASE_USER: 62 conn_ string = "user=%s %s" % (settings.DATABASE_USER, conn_string)65 conn_params['user'] = settings.DATABASE_USER 63 66 if settings.DATABASE_PASSWORD: 64 conn_ string += " password='%s'" %settings.DATABASE_PASSWORD67 conn_params['password'] = settings.DATABASE_PASSWORD 65 68 if settings.DATABASE_HOST: 66 conn_ string += " host=%s" %settings.DATABASE_HOST69 conn_params['host'] = settings.DATABASE_HOST 67 70 if settings.DATABASE_PORT: 68 conn_ string += " port=%s" %settings.DATABASE_PORT69 self.connection = Database.connect( conn_string, **self.options)71 conn_params['port'] = settings.DATABASE_PORT 72 self.connection = Database.connect(**conn_params) 70 73 self.connection.set_isolation_level(1) # make transactions transparent to all cursors 71 74 self.connection.set_client_encoding('UTF8') 72 75 cursor = self.connection.cursor()