Ticket #1051: ticket_1051_rev6098.diff
File ticket_1051_rev6098.diff, 3.7 KB (added by , 17 years ago) |
---|
-
django/db/backends/postgresql/base.py
81 81 82 82 def _cursor(self, settings): 83 83 set_tz = False 84 set_path = False 84 85 if self.connection is None: 85 86 set_tz = True 86 87 if settings.DATABASE_NAME == '': … … 95 96 conn_string += " host=%s" % settings.DATABASE_HOST 96 97 if settings.DATABASE_PORT: 97 98 conn_string += " port=%s" % settings.DATABASE_PORT 99 if settings.DATABASE_SCHEMAS: 100 set_path = True 98 101 self.connection = Database.connect(conn_string, **self.options) 99 102 self.connection.set_isolation_level(1) # make transactions transparent to all cursors 100 103 cursor = self.connection.cursor() 101 104 if set_tz: 102 105 cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE]) 106 if set_path: 107 cursor.execute("SET search_path TO %s", settings.DATABASE_SCHEMAS) 103 108 cursor.execute("SET client_encoding to 'UNICODE'") 104 109 cursor = UnicodeCursorWrapper(cursor, 'utf-8') 105 110 return cursor -
django/db/backends/postgresql_psycopg2/base.py
43 43 44 44 def _cursor(self, settings): 45 45 set_tz = False 46 set_path = False 46 47 if self.connection is None: 47 48 set_tz = True 48 49 if settings.DATABASE_NAME == '': … … 57 58 conn_string += " host=%s" % settings.DATABASE_HOST 58 59 if settings.DATABASE_PORT: 59 60 conn_string += " port=%s" % settings.DATABASE_PORT 61 if settings.DATABASE_SCHEMAS: 62 set_path = True 60 63 self.connection = Database.connect(conn_string, **self.options) 61 64 self.connection.set_isolation_level(1) # make transactions transparent to all cursors 62 65 self.connection.set_client_encoding('UTF8') … … 64 67 cursor.tzinfo_factory = None 65 68 if set_tz: 66 69 cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE]) 70 if set_path: 71 cursor.execute("SET search_path TO %s", settings.DATABASE_SCHEMAS) 67 72 return cursor -
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 = '' # Only used with postgresq to support multiple schemas 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. -
docs/settings.txt
316 316 317 317 The username to use when connecting to the database. Not used with SQLite. 318 318 319 DATABASE_SCHEMAS 320 ---------------- 321 322 Default: ``''`` (Empty string) 323 324 On databases supporting Schemas, like PostgreSQL, the search_path will be 325 set to the value of this setting which is, by default, ``public``. 326 327 Please, note that currently the only backend which schema support is PostgreSQL. 328 319 329 DATE_FORMAT 320 330 ----------- 321 331