sudo apt-get install python-setuptools
sudo apt-get install libmysqld-dev
sudo apt-get install python-dev
安装好这些依赖库以后再安装就不会有问题了:
python setup.py build
sudo python setup.py install
修改数据库的默认拉丁编码为UTF8编码:
[mysqld]
character_set_server=utf8
init_connect=\'SET NAMES utf8\'
在使用API操作前先设置编码格式:
conn.set_character_set(\'utf8\')
cur.execute(\'SET NAMES utf8;\')
cur.execute(\'SET CHARACTER SET utf8;\')
cur.execute(\'SET character_set_connection=utf8;\')
创建数据库时指定编码格式(第一个为按gbk编码,第二个按utf8编码):
CREATE DATABASE `test2` DEFAULT CHARACTER SET gbk COLLATE gbk_chinese_ci;
CREATE DATABASE `test2` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
上一篇:Django学习笔记