1. Hajime Nakagami
  2. sqlalchemy


danring  committed 1703b51

Fix mysql+gaerdbms dialect for changed exception format

googleappengine v1.7.5 changed the exception format to be
incompatible with MySQLDialect_gaerdbms#_extract_error_code

This fix works for both old- and new-style exceptions.

Changes causing the breakage:

  • Participants
  • Parent commits b0eca5b
  • Branches default

Comments (0)

Files changed (1)

File lib/sqlalchemy/dialects/mysql/gaerdbms.py

View file
         return [], opts
     def _extract_error_code(self, exception):
-        match = re.compile(r"^(\d+):").match(str(exception))
+        match = re.compile(r"^(\d+):|^\((\d+),").match(str(exception))
         # The rdbms api will wrap then re-raise some types of errors
         # making this regex return no matches.
-        code = match.group(1) if match else None
+        code = match.group(1) or match.group(2) if match else None
         if code:
             return int(code)