加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
django_2_2_pymysql_patch.py 733 Bytes
一键复制 编辑 原始数据 按行查看 历史
import django
from django.utils.encoding import force_text
if (2, 2) <= django.VERSION < (3,):
# Django 2.2.x is incompatible with PyMySQL.
# This monkey patch backports the Django 3.0+ code.
from django.db.backends.mysql.operations import DatabaseOperations
def last_executed_query(self, cursor, sql, params):
# With MySQLdb, cursor objects have an (undocumented) "_executed"
# attribute where the exact query sent to the database is saved.
# See MySQLdb/cursors.py in the source distribution.
# MySQLdb returns string, PyMySQL bytes.
return force_text(getattr(cursor, '_executed', None), errors='replace')
DatabaseOperations.last_executed_query = last_executed_query
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化