如何配置 python mysql.connector 以在没有字节数组 b'' 的情况下转换长文本字段

问题描述

代码当前检查 type(bol)==bytearray,但如何让它对 longtext 列执行相同的操作?我试过 use_pure = true/false 以及 raw = true/false。我安装了 MysqL-python-connector 8.0.6,运行 python 3.5.4

对于 b'data' 列,它将返回 data vs longtext

class MyConverter(MysqL.connector.conversion.MysqLConverter):

    def row_to_python(self,row,fields):
        row = super(MyConverter,self).row_to_python(row,fields)

        def to_unicode(col):
            if type(col) == bytearray:
                return col.decode('utf-8')
            
            return col

        return[to_unicode(col) for col in row]

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)