当前位置:Gxlcms > 数据库问题 > python链接mysql数据库

python链接mysql数据库

时间:2021-07-01 10:21:17 帮助过:2人阅读

import MySQLdb
conn=MySQLdb.connect(host=‘127.0.0.1‘,user=‘root‘,passwd=‘123456‘,db=‘08day5‘)
cur=conn.cursor()
#打开数据库
#提取数据
reCount=cur.execute(‘select * from admin‘)
data =cur.fetchall()
print reCount
print data
#关闭数据
cur.close()
conn.close()

python链接mysql数据库

标签:python

人气教程排行