Ticket #1051: postgresql_schemas_r11651.diff
File postgresql_schemas_r11651.diff, 4.7 KB (added by , 15 years ago) |
---|
-
django/db/__init__.py
50 50 connection = backend.DatabaseWrapper({ 51 51 'DATABASE_HOST': settings.DATABASE_HOST, 52 52 'DATABASE_NAME': settings.DATABASE_NAME, 53 'DATABASE_SCHEMAS': settings.DATABASE_SCHEMAS, 53 54 'DATABASE_OPTIONS': settings.DATABASE_OPTIONS, 54 55 'DATABASE_PASSWORD': settings.DATABASE_PASSWORD, 55 56 'DATABASE_PORT': settings.DATABASE_PORT, -
django/db/backends/postgresql/base.py
98 98 99 99 def _cursor(self): 100 100 set_tz = False 101 set_path = False 101 102 settings_dict = self.settings_dict 102 103 if self.connection is None: 103 104 set_tz = True … … 113 114 conn_string += " host=%s" % settings_dict['DATABASE_HOST'] 114 115 if settings_dict['DATABASE_PORT']: 115 116 conn_string += " port=%s" % settings_dict['DATABASE_PORT'] 117 if settings_dict['DATABASE_SCHEMAS']: 118 set_path = True 116 119 self.connection = Database.connect(conn_string, **settings_dict['DATABASE_OPTIONS']) 117 120 self.connection.set_isolation_level(1) # make transactions transparent to all cursors 118 121 connection_created.send(sender=self.__class__) … … 124 127 if self._version[0:2] < (8, 0): 125 128 # No savepoint support for earlier version of PostgreSQL. 126 129 self.features.uses_savepoints = False 130 if set_path: 131 cursor.execute("SET search_path TO %s" % ','.join(settings_dict['DATABASE_SCHEMAS'])) 127 132 cursor.execute("SET client_encoding to 'UNICODE'") 128 133 cursor = UnicodeCursorWrapper(cursor, 'utf-8') 129 134 return cursor -
django/db/backends/postgresql_psycopg2/base.py
75 75 76 76 def _cursor(self): 77 77 set_tz = False 78 set_path = False 78 79 settings_dict = self.settings_dict 79 80 if self.connection is None: 80 81 set_tz = True … … 95 96 conn_params['host'] = settings_dict['DATABASE_HOST'] 96 97 if settings_dict['DATABASE_PORT']: 97 98 conn_params['port'] = settings_dict['DATABASE_PORT'] 99 if settings_dict['DATABASE_SCHEMAS']: 100 set_path = True 98 101 self.connection = Database.connect(**conn_params) 99 102 self.connection.set_client_encoding('UTF8') 100 103 self.connection.set_isolation_level(self.isolation_level) … … 119 122 # versions that support it, but, right now, that's hard to 120 123 # do without breaking other things (#10509). 121 124 self.features.can_return_id_from_insert = True 125 if set_path: 126 cursor.execute("SET search_path TO %s" % ','.join(settings_dict['DATABASE_SCHEMAS'])) 122 127 return cursor 123 128 124 129 def _enter_transaction_management(self, managed): -
django/conf/project_template/settings.py
11 11 12 12 DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 13 13 DATABASE_NAME = '' # Or path to database file if using sqlite3. 14 DATABASE_SCHEMAS = [] # Databse schemas to be used. Only used in PostgreSQL 14 15 DATABASE_USER = '' # Not used with sqlite3. 15 16 DATABASE_PASSWORD = '' # Not used with sqlite3. 16 17 DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3. -
django/conf/global_settings.py
125 125 # Database connection info. 126 126 DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 127 127 DATABASE_NAME = '' # Or path to database file if using sqlite3. 128 DATABASE_SCHEMAS = [] # Databse schemas to be used. Only used in PostgreSQL 128 129 DATABASE_USER = '' # Not used with sqlite3. 129 130 DATABASE_PASSWORD = '' # Not used with sqlite3. 130 131 DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.