Opened 11 years ago

Closed 10 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

Description

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 by Anssi Kääriäinen, 11 years ago

Triage Stage: UnreviewedAccepted

Patches welcome.

comment:2 by Russell Keith-Magee, 11 years ago

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 by Claude Paroz, 11 years ago

I have a branch which more or less supports PyMySQL.
https://github.com/claudep/django/compare/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 by Collin Anderson, 10 years ago

Cc: cmawebsite@… added

See also #22391

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

comment:5 by Collin Anderson, 10 years ago

Resolution: wontfix
Status: newclosed

Closing now that mysqlclient is our official recommended connector.

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