小编kon*_*ong的帖子

MySQLdb不能使用cursorclass

我正在尝试执行以下代码:

import MySQLdb
import MySQLdb.cursors
conn=MySQLdb.connect(host = '127.0.0.1',
                     user = 'root',
                     passwd = 'root',
                     db = 'test',
                     cursorclass = MySQLdb.cursors.DictCursor)
cursor=conn.cursor()
Run Code Online (Sandbox Code Playgroud)

但它给了我以下错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/MySQLdb/connections.py", line 243, in cursor
  AttributeError: 'Connection' object has no attribute 'cursorclass'
Run Code Online (Sandbox Code Playgroud)

为什么是这样?

python mysql-python

3
推荐指数
1
解决办法
4564
查看次数

标签 统计

mysql-python ×1

python ×1