ImportError: No module named ‘exceptions’

The error:

Traceback (most recent call last):
  File "D:\pyhomelib\mainwindow.py", line 19, in <module>
    from sqlquerymodel import SqlQueryModel
  File "D:\pyhomelib\sqlquerymodel.py", line 4, in <module>
    from exceptions import Exception
ImportError: No module named 'exceptions'

The problem:

from exceptions import Exception

Explanation:

In Python 3, exceptions module was removed and all standard exceptions were moved to builtin module. 
Thus meaning that there is no more need to do explicit import of any standard exceptions.

AttributeError: ‘QDateTime’ object has no attribute ‘upper’

Traceback (most recent call last):
File "D:\port\workspace\python\PyQtTest\hris\mdi00\querymodel.py", line 61, in data
return value.upper()
AttributeError: 'QDateTime' object has no attribute 'upper'

The code:

class CustomSqlModel(QSqlQueryModel):
  def data(self, index, role):
    value = super(CustomSqlModel, self).data(index, role)
    if value is not None and role == Qt.DisplayRole:
      if index.column() == 0:
        return '#%s' % value
      elif index.column() == 2:
        return value.upper()          

    if role == Qt.TextColorRole and index.column() == 1:
      return QColor(Qt.blue)

    return value

The problem is at line 8: “return value.upper()”.
I edit the class with adding function hasattr(value, ‘upper’),

class CustomSqlModel(QSqlQueryModel):
  def data(self, index, role):
    value = super(CustomSqlModel, self).data(index, role)
    if value is not None and role == Qt.DisplayRole:
      if index.column() == 0:
        return '#%s' % value
      elif index.column() == 2:
        if hasattr(value, 'upper'):
          return value.upper()

    if role == Qt.TextColorRole and index.column() == 1:
      return QColor(Qt.blue)

    return value