安裝
wget http://tenet.dl.sourceforge.net/project/mysql-python/mysql-python-test/1.2.4b4/MySQL-python-1.2.4b4.tar.gz
tar zxvf MySQL-python-1.2.4b4.tar.gz
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
使用
import MySQLdb
conn = MySQLdb.connect(host="localhost", port=3306, user="root", passwd="root", db="test", charset="utf8")
cursor = conn.cursor()
cursor.execute("show tables")
cursor.fetchone()
cursor.fetchall()