Opened 5 years ago

Closed 3 years ago

#20542 closed Bug (wontfix)

pymysql breaks last_executed_query()

Reported by: christian.oudard@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.5
Severity: Normal Keywords:
Cc: cmawebsite@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


In last_executed_query(), the value returned by cursor._last_executed is unconditionally decoded as utf8. This presumes that it is a byte string with utf8 encoding.

On the MySQLdb driver, this is true, but on pymysql, it returns a unicode string instead. This prevents anyone from running queries containing unicode characters in debug mode while using pymysql.

I can make a patch for this if necessary.

Change History (5)

comment:1 Changed 5 years ago by Anssi Kääriäinen

Triage Stage: UnreviewedAccepted

Patches welcome.

comment:2 Changed 4 years ago by Russell Keith-Magee

Is PyMySQL really a drop in replacement for MySQLdb? It looks to me like the base package name is different, so I don't see how it is possible that this works at all without either an import shim, or a completely different database backend.

comment:3 Changed 4 years ago by Claude Paroz

I have a branch which more or less supports PyMySQL.

Quoting Alex (regarding the above branch):
The right way to do this type of thing is to really split the adapter part of a database backend away from the database part of it. So we can easily have PyMySQL, MySQLdb, psycopg2, pg8000, py-postgresql, postgresql-ctypes, and whatever else shows up, without needing to continually add to the chain of except ImportError.

comment:4 Changed 3 years ago by Collin Anderson

Cc: cmawebsite@… added

See also #22391

Last edited 3 years ago by Collin Anderson (previous) (diff)

comment:5 Changed 3 years ago by Collin Anderson

Resolution: wontfix
Status: newclosed

Closing now that mysqlclient is our official recommended connector.

Note: See TracTickets for help on using tickets.
Back to Top