import MySQLdb
db = MySQLdb.connect("localhost", "root", "123456", "app", charset='utf8' )
cursor = db.cursor()
sql = "SELECT * FROM userInfo WHERE userName ='xsf' "
cursor.execute(sql)
results = cursor.fetchall()
print(results)
runfile('C:/Users/1/Desktop/test/readMysql.py', wdir='C:/Users/1/Desktop/test')
(('xsf', '654321'),)
python 链接本地MySQL数据库
最新推荐文章于 2024-10-12 11:36:49 发布