Home  >  Article  >  Database  >  python和mysql连接数据库的问题

python和mysql连接数据库的问题

WBOY
WBOYOriginal
2016-06-06 09:38:061275browse

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有什么区别?谢谢各位老师

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn