1、如果还未安装,我们可以使用以下命令安装最新版的 PyMySQL:
$ pip install PyMySQL
2、如果出错,请参照以下网址
http://blog.csdn.net/linuxpassion/article/details/51902521
3、以下是代码
```
111
```
#coding:utf-8
import pymysql
db=pymysql.connect("172.16.40.88","root","tvfan2015","live",use_unicode=True,charset="utf8")
cursor = db.cursor()
cursor.execute('SET NAMES utf8;')
cursor.execute('SET CHARACTER SET utf8;')
cursor.execute('SET character_set_connection=utf8;')
sql ="SELECT * FROM tb_channel WHERE CNAME='北京财经'"
cursor.execute(sql)
data = cursor.fetchone()
print(data)
db.close()
```
注意: # 若没有 use_unicode=True, charset="utf8" 那么就会发生如题错误:
网友评论