文章会有【原创】或者【转载】标示,部分来自Google Baidu的学习结果 {Java/PHP/Python/Ruby/Go}

Python 链接Mysql  


一:先看例子
import MySQLdb
#lj mysql
conn = MySQLdb.connect(host="localhost",user="root",passwd="",db="hhy")
#yb
cursor = conn.cursor()
#select
sel = cursor.execute('select * from test')
#one
#fetchone()
#fetchmany(5)
#res
results = cursor.fetchall()
for i in results:
    print i;
conn.close()

注意MySQLdb  注意大小写
二:结果