故障转移选项在 mysql.connector 中引发错误

failover option throws error in mysql.connector

这是我的代码:

import mysql.connector

config = {
        'user': 'bb123',\
        'password': 'tt',\
        'host': 'adb',\
        'failover': 'bdb',\
        }

 self.conn = mysql.connector.connect(**self.config)

但是,我收到此错误:

return _get_failover_connection(**kwargs)
  File "C:\Python27\lib\site-packages\mysql\connector\__init__.py", line 109, in _get_failover_connection
    diff = set(server.keys()) - support_cnx_args
AttributeError: 'str' object has no attribute 'keys'

如何启用故障转移数据库?

failover 值应该是包含故障转移服务器连接详细信息的列表或字典元组。例如:

failoverConfig = {
                'user': 'failover_user',\
                'password': 'failover_password',\
                'host': 'failover_host',\
                }

config = {
        'user': 'testeng',\
        'password': 'testeng',\
        'host': 'adb',\
        'failover': [failover_config],\
        }