1、安装Python的MySQL编程库(win7 64位)
下载 MySQL-python-1.2.3.win-amd64-py2.7.exe ,运行安装。
2、MySQL的Python代码实例
import MySQLdb
try:
conn=MySQLdb.connect(host='912.168.0.1',user='user',passwd='password',db='tablename',port=3306)
cur=conn.cursor()
cur.execute('select * from device limit 10')
cur.close()
conn.close()
except MySQLdb.Error,e:
print "Mysql Error %d: %s" % (e.args[0], e.args[1])
更多 http://www.cnblogs.com/rollenholt/archive/2012/05/29/2524327.html