1、python3.6不支持 import MySQLdb 改用为 import pymysql 模块,需要自行安装模块pymysql。
2、python3.6安装模块pymysql
3、mac 操作环境下 命令行安装:sudo pip install pymysql
4、python3.6连接mysql数据库
def __init__(self): self.client = pymysql.connect( host='127.0.0.1', port=3306, user='qrcode', passwd='Mimag', db='test', charset='utf8', ) self.cur = self.client.cursor() # 获取操作游标