我正在尝试通过python连接MySQL数据库。我最初安装的mysql-connector无法正常工作。后来我安装了mysql-connector-python,连接成功。但是当我尝试使用cursor()时,出现错误:
代码:
导入_mysql_connector
mydb = _mysql_connector.MySQL()。connect(host =“ localhost”,user =“ root”,password =“ 1234”)] >>
mycursor = mydb.cursor()
mycursor.execute(“显示数据库”)
错误:AttributeError:'NoneType'对象没有属性'cursor'
我正在尝试通过python连接MySQL数据库。我最初安装的mysql-connector无法正常工作。后来我安装了mysql-connector-python,连接成功。但是当我尝试...
您正在尝试使用C Extension Module进行连接。这是基本的Connector示例: