当前位置:Gxlcms > mysql > python和mysql连接数据库的问题

python和mysql连接数据库的问题

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

mysqlpythonmysqldb

 import mysql.connectorcnx = mysql.connector.connect(user='scott', password='tiger',host='127.0.0.1',database='employees')cnx.close()方法二:import MySQLdbdb = MySQLdb.connect(host="localhost", # your host, usually localhost                     user="john", # your username                      passwd="megajonhy", # your password                      db="jonhydb") # name of the data basecur = db.cursor() cur.execute("SELECT * FROM YOUR_TABLE_NAME")

请问各位老师这个mysqlconnector 和MySQLdb有什么区别?谢谢各位老师

人气教程排行