Rumah > Artikel > pangkalan data > python和mysql连接数据库的问题
mysqlpythonmysqldb
<code> 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")</code>
请问各位老师这个mysqlconnector 和MySQLdb有什么区别?谢谢各位老师