Python MySQL

python -m pip install mysql-connector

创建数据库连接

import mysql.connector
 
mydb = mysql.connector.connect(
  host="localhost",       # 数据库主机地址
  user="yourusername",    # 数据库用户名
  passwd="yourpassword"   # 数据库密码
)
 
print(mydb)

输出所有数据库列表:

参考

Python MySQL - mysql-connector 驱动 -  https://www.runoob.com/python3/python-mysql-connector.html

Connecting to MySQL Using Connector/Python - https://dev.mysql.com/doc/connector-python/en/connector-python-example-connecting.html

Python MySQL - mysql-connector 驱动

原文地址:https://www.cnblogs.com/ilovecpp/p/12802806.html