使用Python操作MySQL

时间:2014-12-10 21:08:08   收藏:0   阅读:207

比较简单,直接上代码了。

import MySQLdb

def showResult(res):
        for i in res:
                print i

conn=MySQLdb.connect(host="localhost",user="root",passwd="123456",db="cloud",charset="utf8")
cursor = conn.cursor()
cursor.execute(select * from filelist)
res = cursor.fetchall()
showResult(res)

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!