  
  class CursorDebugWrapper(object):
      def __init__(self, cursor, db):
          self.cursor = cursor
          self.db = db # Instance of a BaseDatabaseWrapper subclass
  
      def execute(self, sql, params=()):
          start = time()
          try:
              return self.cursor.execute(sql, params)
 
</s> remove class CursorDebugWrapper(object):
    def __init__(self, cursor, db):
 </s> add class CursorWrapper(object):
    def __init__(self, cursor, connection): </s> remove             sql = self.db.ops.last_executed_query(self.cursor, sql, params)
            self.db.queries.append({
 </s> add             sql = self.connection.ops.last_executed_query(self.cursor, sql, params)
            self.connection.queries.append({ </s> remove             return self.make_debug_cursor(cursor)
 </s> add             cursor = self.make_debug_cursor(self._cursor())
        else:
            cursor = util.CursorWrapper(self._cursor(), self) </s> remove         cursor = self._cursor()
 </s> add  </s> remove             self.db.queries.append({
 </s> add             self.connection.queries.append({
        self.connection = connection

    def __getattr__(self, attr):
        if self.connection.is_managed():
            self.connection.set_dirty()
        if attr in self.__dict__:
            return self.__dict__[attr]
        else:
            return getattr(self.cursor, attr)

    def __iter__(self):
        return iter(self.cursor)


class CursorDebugWrapper(CursorWrapper):
  
  class CursorDebugWrapper(object):
      def __init__(self, cursor, db):
          self.cursor = cursor
        self.connection = connection

    def __getattr__(self, attr):
        if self.connection.is_managed():
            self.connection.set_dirty()
        if attr in self.__dict__:
            return self.__dict__[attr]
        else:
            return getattr(self.cursor, attr)

    def __iter__(self):
        return iter(self.cursor)


class CursorDebugWrapper(CursorWrapper):
  
      def execute(self, sql, params=()):
          start = time()
          try:
              return self.cursor.execute(sql, params)
keep keep keep keep replace keep keep keep keep keep
 Fixed #9964 -- Ensure that all database operations make transactions dirty, not just write operations. Many thanks to Shai Berger for his work and persistence on this issue.

This is BACKWARDS INCOMPATIBLE for anyone relying on the current behavior that allows manually managed read-only transactions to be left dangling without a manual commit or rollback.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15493 bcc190cf-cafb-0310-a4f2-bffc1f526a37 
django/db/backends/util.py