1. database to utf8 in
CREATE DATABASE spiderTest DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
2. the table to utf8
use spiderTest
CREATE TABLE test
(
ID INT(18) PRIMARY KEY AUTO_INCREMENT,
test1 VARCHAR(500),
test2 VARCHAR(100),
test3 VARCHAR(100)
) ENGINE=INNODB CHARSET=utf8
3. Python chain database also utf8
import tracebackimport pymysql,pymssql
Import PooledDB DBUtils.PooledDB from
# tmp = "INSERT INTO exch_no_rand_auto (stkcode) values (% S);" #sql template string
# l_tupple = [(i,) for i in range (100)] # parameters to generate data, list in nested tuple
config = {
'Host': 'localhost'
, 'User': 'the root'
, 'password': '123456'
, 'Database': 'spidertest'
, 'charset': 'UTF8'
, 'Port' : 3306 # Note int port instead STR
}
# calling function
DB = pymysql.connect (** config)
4. Python file also preferably plus
# Encoding = utf8
statement utf8 encoding
5. MySQL execute the following query,
SHOW VARIABLES LIKE 'character%';
Chou Chou who is not utf8
The change character_set_server:
SET character_set_server='utf8';
This time I was in Europe, and Europe does not know you in Europe, not Europe again Soso it, certainly still coding problem, do not know where the leak is not set