python连接mysql

1.http://sourceforge.net/projects/mysql-python 下载模块,安装,适用于windows

2.import MySQLdb

 conn = MySQLdb.connect(host='hostname', user='user', passwd='password', db='test', charset='utf8')

 cursor = conn.cursor()

 cursor.execute('show tables')

 conn.commit()

 cursor.close()

 conn.close()

完!


你可能感兴趣的:(mysql,python)