Ticket #1051: django-postgresql-schemas-v2.diff

File django-postgresql-schemas-v2.diff, 1.3 KB (added by Landon Fuller <landonf@…>, 18 years ago)

PostgreSQL SCHEMA support (Updated)

  • django/conf/project_template/settings.py

    === django/conf/project_template/settings.py
    ==================================================================
     
    1111
    1212DATABASE_ENGINE = ''           # '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/db/backends/postgresql/base.py

    === django/db/backends/postgresql/base.py
    ==================================================================
     
    4444            self.connection.set_isolation_level(1) # make transactions transparent to all cursors
    4545        cursor = self.connection.cursor()
    4646        cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE])
     47        if settings.DATABASE_SCHEMAS:
     48            cursor.execute("SET search_path TO %s;" % settings.DATABASE_SCHEMAS)
    4749        if settings.DEBUG:
    4850            return util.CursorDebugWrapper(cursor, self)
    4951        return cursor
Back to Top