Board logo

标题: python之MySQLdb实操测试 [打印本页]

作者: xiexie    时间: 2018-6-21 15:13     标题: python之MySQLdb实操测试

调试费了一些周折,但还是成功了,摸索中前进比较难,处处是坑。import MySQLdb
db = MySQLdb.connect(host='127.0.0.1',user='root',passwd='pawwd',db='db',charset='gbk')
cur = db.cursor()
cur.execute("select * from user_info")
#res = cur.fetchall()
res = cur.fetchone()
print(res)
while res:
    print res
    res = cur.fetchone()
db.close()




欢迎光临 PHP开发笔记 (http://phpvi.com/) Powered by Discuz! 6.1.0