conn.encoders[SafeBytes] = conn.encoders[bytes] KeyError: <class 'bytes'>

问题描述:Django连接mysql数据库,修改了setting.py文件后,启动服务器报错

错误截图如下:

解决方法:

1、pip install pymsql

2、在setting.py同目录下的__init__.py文件中加上如下两行代码

import pymysql

pymysql.install_as_MySQLdb()

conn.encoders[SafeBytes] = conn.encoders[bytes] KeyError: <class 'bytes'>

原文地址:https://www.cnblogs.com/heiao10duan/p/10342261.html

时间: 2024-07-31 13:33:15

conn.encoders[SafeBytes] = conn.encoders[bytes] KeyError: <class 'bytes'>的相关文章

数据库conn.Close()与conn.dispose(方法的区别

Close()是关闭链接,Dispose()是释放对象(垃圾回收器回收)比如Conn对象,Close过后,Conn这个对象本身还存在内存中,还在连接池中,需要在使用的时候,可以直接用.而调用Dispose()后,释放conn对象所占用的资源,释放后这个对象就不可用了,处于等待垃圾回收器回收状态;Conn对象被回收,不会再放入连接池,Conn对象已经不存在了,下次再需要使用的时候,需要重新创建(New) 如果所有的连接都被Dispose的话,每次使用数据库都必须重新创建连接,这样很耗费资源.因此不

conn.execute的用法详解

conn.execute的用法 conn.execute.rs.open之间的差别,conn.execute.rs.open.command.execute方法用法大大不同 通常形成记录集可以使用 Set rs=conn.execute(SQL) 或直接 rs=CONN.execute(SQL) 和 Set rs=Server.CreateObject("ADODB.Recordset") rs.open SQL,CONN,0,1 或 rs.open SQL,CONN 这种情况 通常o

Golang之bytes.buffer

bytes.buffer是一个缓冲byte类型的缓冲器存放着都是byte Buffer 是 bytes 包中的一个 type Buffer struct{-} A buffer is a variable-sized buffer of bytes with Read and Write methods. The zero value for Buffer is an empty buffer ready to use. (是一个变长的 buffer,具有 Read 和Write 方法. Buf

Python 编码,str,bytes

什么是明文 "明文"是可以是文本,音乐,可以编码成mp3文件.明文可以是图像的,可以编码为gif.png或jpg文件.明文是电影的,可以编码成wmv文件.不一而足. 什么是编码?把明文变成计算机语言 为什么要用Unicode来编码?可以记录所有语言,而且编码方式不止一种 python str与bytes之间的转换 # bytes object b = b"example" # str object s = "example" # str to b

ORA-04031:unable to allocate 4120 bytes of shared memory ‘obj stat mem’故障解决

客户报表库,HP-ux B11.31 IA64 FOR Oracle 10.2.0.5.0 RAC系统短信过滤alert日志告警 ORA-00604: error occurred at recursive SQL level 1 ORA-04031:unable to allocate 4120 bytes of shared memory ("shared pool","select f.file#, f.block#, f....","Typeche

Python标准库:内置函数bytes([source[, encoding[, errors]]])

返回一个新的数组对象,这个数组对象不能对数组元素进行修改.每个元素值范围: 0 <= x < 256.bytes函数与bytearray函数主要区别是bytes函数产生的对象的元素不能修改,而bytearray函数产生的对象的元素可以修改.因此,除了可修改的对象函数跟bytearray函数不一样之外,其它使用方法全部是相同的.最后它的参数定义方式也与bytearray函数是一样的. 例子: #bytes()函数 a = bytes('abc', 'utf-8') print(a) b = by

go语言中bytes包的常用函数,Reader和Buffer的使用

bytes中常用函数的使用: package main; import ( "bytes" "fmt" "unicode" ) //bytes包中实现了大量对[]byte操作的函数和两个最主要的Reader和Buffer两个结构 func main() { str := "aBcD"; //转为小写 fmt.Println(string(bytes.ToLower([]byte(str)))); //转为大写 fmt.Prin

int 4 bytes

http://waynewhitty.ie/blog-post.php?id=19 MySQL - INT(11) vs BIGINT(11) vs TINYINT(11) This seems to be a common misconception among many developers who interact with MySQL. The assumption is that the 11 inINT(11) determines the maximum size of the i

bytes和bytearray总结

The core built-in types for manipulating binary data are bytes and bytearray. They are supported by memoryview which uses the buffer protocol to access the memory of other binary objects without needing to make a copy. bytearray objects are a mutable