如何将Python字典转换为MySQL类型?

时间:2020-07-21 20:01:14

标签: python mysql database

我正在尝试将Python词典存储在MySQL数据库中。我收到类似下面列出的错误:

AttributeError: 'MySQLConverter' object has no attribute '_dict_to_mysql'

    raise TypeError("Python '{0}' cannot be converted to a "
TypeError: Python 'dict' cannot be converted to a MySQL type

mysql.connector.errors.ProgrammingError: Failed processing format-parameters; Python 'dict' cannot be converted to a MySQL type'dict' cannot be converted to a MySQL type

我当前的代码是:

config = {'ban_message': 'test'}

cursor.execute("INSERT INTO Dashboard (guild_id, configs) VALUES (%s, %s)", (638178402310029322, config))

任何建议都会有用!

0 个答案:

没有答案