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

python和mysql连接数据库的问题

WBOY
Release: 2016-06-06 09:38:06
Original
1290 people have browsed it

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>
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template