1. 安装
1.1 下载wheel文件
网上搜多到的多数都是这种方案。从uci.edu按照自己的系统和Python版本现在wheel文件。比如我是Python3.6 32的版本。
uci.edu提供的wheel文件
1.2 安装
python -m pip install mysqlclient-1.4.6-cp36-cp36m-win32.whl
离线安装
2. 使用
2.1 查询
返回数据默认每一行做为一个tuple,多行返回的结构是tuple(tuple),可以通过制定db.cursor(MySQLdb.cursors.DictCourse)将返回结构修改为tuple(dict),列名为key,默认的Cursor类型为MySQLdb.cursors.Course
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import MySQLdb
db = MySQLdb.connect(host="192.168.36.33", port=3306, db="db", user="user", password="pwd", charset='utf8')
# cursor = db.cursor(MySQLdb.cursors.DictCursor)
cursor = db.cursor()
c