Opened 22 months ago

Closed 2 months 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 Changed 22 months ago by akaariai

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Patches welcome.

comment:2 Changed 16 months ago by russellm

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 16 months ago by claudep

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 Changed 8 months ago by CollinAnderson

  • Cc cmawebsite@… added

See also #22391

Last edited 8 months ago by CollinAnderson (previous) (diff)

comment:5 Changed 2 months ago by collinanderson

  • Resolution set to wontfix
  • Status changed from new to closed

Closing now that mysqlclient is our official recommended connector.

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