Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions pymysql/cursors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re
import warnings
from . import err


Expand Down Expand Up @@ -352,16 +353,29 @@ def __next__(self):
raise StopIteration
return row

Warning = err.Warning
Error = err.Error
InterfaceError = err.InterfaceError
DatabaseError = err.DatabaseError
DataError = err.DataError
OperationalError = err.OperationalError
IntegrityError = err.IntegrityError
InternalError = err.InternalError
ProgrammingError = err.ProgrammingError
NotSupportedError = err.NotSupportedError
def __getattr__(self, name):
# DB-API 2.0 optional extension says these errors can be accessed
# via Connection object. But MySQLdb had defined them on Cursor object.
if name in (
"Warning",
"Error",
"InterfaceError",
"DatabaseError",
"DataError",
"OperationalError",
"IntegrityError",
"InternalError",
"ProgrammingError",
"NotSupportedError",
):
# Deprecated since v1.1
warnings.warn(
"PyMySQL errors hould be accessed from `pymysql` package",
DeprecationWarning,
stacklevel=2,
)
return getattr(err, name)
raise AttributeError(name)


class DictCursorMixin:
Expand Down