Python MySql 连接器准备好的语句和字典类

use*_*290 4 python mysql mysql-connector python-3.x

如何使我的光标成为准备好的语句和字典。我有以下内容。

 cursor(cursor_class = MySQLCursorPrepared)
 prints <class 'mysql.connector.cursor.MySQLCursorPrepared'>
 cursor(dictionary = True)
 prints <class 'mysql.connector.cursor.MySQLCursorDict'>
Run Code Online (Sandbox Code Playgroud)

所以我用字典覆盖了准备好的语句。我正在为 python3 使用 mysql 连接器。

我试过了

 cursor(prepared=True,dictionary=True)
Run Code Online (Sandbox Code Playgroud)

错误与

Cursor not available with given criteria: dictionary, prepared
Run Code Online (Sandbox Code Playgroud)

有趣的是

cursor(cursor_class = MySQLCursorPrepared,dictionary = True)
Run Code Online (Sandbox Code Playgroud)

我没有收到错误,但数据不是字典类型。

Sal*_*Car 7

我也有同样的问题。Prepared 和 Dictionary 不能一起使用。

我报告了错误:https : //bugs.mysql.com/bug.php?id=92700

现在我们等待;)

  • 谢谢。我找到了一个解决方法。我使它成为一个准备好的语句,然后使用 dictzip 将数据放入字典中。 (2认同)