首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Python3 - Mysql - cursor()获得意外的关键字参数'dictionary‘

Python3 - Mysql - cursor()获得意外的关键字参数'dictionary‘
EN

Stack Overflow用户
提问于 2021-06-03 16:15:00
回答 1查看 40关注 0票数 1

这个程序在Ubuntu 10上运行得很好,但在我的Debian 8上就不行了。

代码语言:javascript
运行
复制
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import mysql.connector

conn = mysql.connector.connect(
       user='eric', 
       password='***',
       host='localhost',
       database='eric'
)

curs = conn.cursor(dictionary=True)

错误

代码语言:javascript
运行
复制
Traceback (most recent call last):
  File "./exo.py", line 19, in <module>
    curs = conn.cursor(dictionary=True)
TypeError: cursor() got an unexpected keyword argument 'dictionary'

环境

代码语言:javascript
运行
复制
pip3 list|grep mysql -> None

dpkg -l|grep mysql|grep python
ii  python3-mysql.connector          1.2.3-2                              all          pure Python implementation of MySQL Client/Server protocol (Python3)

你能帮我吗?谢谢

EN

回答 1

Stack Overflow用户

发布于 2021-06-03 19:58:29

感谢snakecharmed ..。

https://dev.mysql.com/doc/relnotes/connector-python/en/news-2-0-0.html

mysql.connector.cursor模块支持四个新的游标类:

MySQLCursorDict游标类将每行作为字典返回。每个字典对象的键都是MySQL的列名

结果。

cursor = cnx.cursor(dictionary=True)

因此,在1.2.3版本的mysql.connector上不存在dictionnary=True

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67817829

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档