Ticket #1051: django_pgsql_schemas_rev4201.patch

File django_pgsql_schemas_rev4201.patch, 2.0 KB (added by telenieko@…, 18 years ago)

Added the same changes on psycopg2

  • 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

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

     
    4646        cursor = self.connection.cursor()
    4747        cursor.tzinfo_factory = None
    4848        cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE])
     49        if settings.DATABASE_SCHEMAS:
     50            cursor.execute("SET search_path TO %s;" % settings.DATABASE_SCHEMAS)
    4951        if settings.DEBUG:
    5052            return util.CursorDebugWrapper(cursor, self)
    5153        return cursor
Back to Top