mysql连接模块 mysql.connector
连接实例: import mysql.connector config={'host':'127.0.0.1', 'user':'root', 'password':'root', 'port':'3306', 'database':'abcd' } try: cnn=mysql.connector.connect(**config) print('数据库连接成功!') except mysql.connector.Error as e: print('数据库连接失败',str(e))