Ticket #1051: django-postgresql-schemas.diff

File django-postgresql-schemas.diff, 1.9 KB (added by Mao Xizeng <mao.xizeng@…>, 19 years ago)
  • django/conf/project_template/settings.py

     
    1111
    1212DATABASE_ENGINE = 'postgresql' # 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
    1313DATABASE_NAME = ''             # Or path to database file if using sqlite3.
     14DATABASE_SCHEMAS = ''          # Only used with postgresq to support multiple schemas
    1415DATABASE_USER = ''             # Not used with sqlite3.
    1516DATABASE_PASSWORD = ''         # Not used with sqlite3.
    1617DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
  • django/core/db/backends/postgresql.py

     
    1515        self.queries = []
    1616
    1717    def cursor(self):
    18         from django.conf.settings import DATABASE_USER, DATABASE_NAME, DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD, DEBUG, TIME_ZONE
     18        from django.conf.settings import DATABASE_ENGINE, DATABASE_USER, DATABASE_NAME, DATABASE_SCHEMAS, DATABASE_HOST, DATABASE_PORT, DATABASE_PASSWORD, DEBUG, TIME_ZONE
    1919        if self.connection is None:
    2020            if DATABASE_NAME == '':
    2121                from django.core.exceptions import ImproperlyConfigured
     
    3333            self.connection.set_isolation_level(1) # make transactions transparent to all cursors
    3434        cursor = self.connection.cursor()
    3535        cursor.execute("SET TIME ZONE %s", [TIME_ZONE])
     36        if DATABASE_ENGINE == 'postgresql' and DATABASE_SCHEMAS:
     37            cursor.execute("SET search_path TO %s; " % DATABASE_SCHEMAS)
    3638        if DEBUG:
    3739            return base.CursorDebugWrapper(cursor, self)
    3840        return cursor
Back to Top