              transaction.savepoint_commit(sid, using=self.db)
              return obj, True
          except DatabaseError:
              transaction.savepoint_rollback(sid, using=self.db)
              exc_info = sys.exc_info()
              try:
                  return self.get(**lookup), False
              except self.model.DoesNotExist:
                  # Re-raise the DatabaseError with its original traceback.
                  six.reraise(*exc_info)
  
      def _extract_model_params(self, defaults, **kwargs):
          """
          Prepares `lookup` (kwargs that are valid model attributes), `params`
          (for creating a model instance) and `filtered_defaults` (defaults
 
</s> remove         except DatabaseError:
 </s> add         except DatabaseError as e: </s> remove             sid = transaction.savepoint(using=self.db)
 </s> add  </s> remove             six.reraise(sys.exc_info())
 </s> add             six.reraise(*sys.exc_info()) </s> remove             obj = self.model(**params)
            sid = transaction.savepoint(using=self.db)
 </s> add 
            if isinstance(e, IntegrityError):
                try:
                    return self.get(**lookup), False
                except self.model.DoesNotExist:
                    pass
            six.reraise(*sys.exc_info())
              transaction.savepoint_commit(sid, using=self.db)
              return obj, True
          except DatabaseError:
              transaction.savepoint_rollback(sid, using=self.db)
            if isinstance(e, IntegrityError):
                try:
                    return self.get(**lookup), False
                except self.model.DoesNotExist:
                    pass
            six.reraise(*sys.exc_info())
            if isinstance(e, IntegrityError):
                try:
                    return self.get(**lookup), False
                except self.model.DoesNotExist:
                    pass
            six.reraise(*sys.exc_info())
            if isinstance(e, IntegrityError):
                try:
                    return self.get(**lookup), False
                except self.model.DoesNotExist:
                    pass
            six.reraise(*sys.exc_info())
            if isinstance(e, IntegrityError):
                try:
                    return self.get(**lookup), False
                except self.model.DoesNotExist:
                    pass
            six.reraise(*sys.exc_info())
            if isinstance(e, IntegrityError):
                try:
                    return self.get(**lookup), False
                except self.model.DoesNotExist:
                    pass
            six.reraise(*sys.exc_info())
            if isinstance(e, IntegrityError):
                try:
                    return self.get(**lookup), False
                except self.model.DoesNotExist:
                    pass
            six.reraise(*sys.exc_info())
  
      def _extract_model_params(self, defaults, **kwargs):
          """
          Prepares `lookup` (kwargs that are valid model attributes), `params`
          (for creating a model instance) and `filtered_defaults` (defaults
keep keep keep keep replace replace replace replace replace replace keep keep keep keep keep
 Fixed #20761 -- Fixed DatabaseError handling in get_or_create and update_or_create. 
django/db/models/query.py