diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-01-09 06:08:40 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-01-09 06:08:40 +0000 |
| commit | 83cb2218bc73707f2c15a40caef97e375c4f1175 (patch) | |
| tree | 395bab54ac4f6d3b65ef25d16fbba419fc704e5b /django/db | |
| parent | b824d803cef720fcf39ee19c54a14da811ea1c3d (diff) | |
queryset-refactor: Merged from trunk up to [7002].
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7004 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db')
| -rw-r--r-- | django/db/backends/oracle/base.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py index cd830413fc..70f5688d1a 100644 --- a/django/db/backends/oracle/base.py +++ b/django/db/backends/oracle/base.py @@ -413,6 +413,7 @@ class DatabaseWrapper(BaseDatabaseWrapper): return self.connection is not None def _cursor(self, settings): + cursor = None if not self._valid_connection(): if len(settings.DATABASE_HOST.strip()) == 0: settings.DATABASE_HOST = 'localhost' @@ -422,16 +423,25 @@ class DatabaseWrapper(BaseDatabaseWrapper): else: conn_string = "%s/%s@%s" % (settings.DATABASE_USER, settings.DATABASE_PASSWORD, settings.DATABASE_NAME) self.connection = Database.connect(conn_string, **self.options) + cursor = FormatStylePlaceholderCursor(self.connection) + # Set oracle date to ansi date format. This only needs to execute + # once when we create a new connection. + cursor.execute("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD' " + "NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF'") try: self.oracle_version = int(self.connection.version.split('.')[0]) except ValueError: pass - cursor = FormatStylePlaceholderCursor(self.connection) + try: + self.connection.stmtcachesize = 20 + except: + # Django docs specify cx_Oracle version 4.3.1 or higher, but + # stmtcachesize is available only in 4.3.2 and up. + pass + if not cursor: + cursor = FormatStylePlaceholderCursor(self.connection) # Default arraysize of 1 is highly sub-optimal. cursor.arraysize = 100 - # Set oracle date to ansi date format. - cursor.execute("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD'") - cursor.execute("ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF'") return cursor class FormatStylePlaceholderCursor(Database.Cursor): @@ -506,7 +516,10 @@ class FormatStylePlaceholderCursor(Database.Cursor): return Database.Cursor.executemany(self, query, new_param_list) def fetchone(self): - return to_unicode(Database.Cursor.fetchone(self)) + row = Database.Cursor.fetchone(self) + if row is None: + return row + return tuple([to_unicode(e) for e in row]) def fetchmany(self, size=None): if size is None: |
