我正在为Python使用mysql.connector
。以下是我的连接参数。如何设置超时或增加默认超时?
class Config(object):
"""Configure me so examples work
Use me like this:
mysql.connector.Connect(**Config.dbinfo())
"""
HOST = dbhost
DATABASE = dbdatabase
USER = dbusername
PASSWORD = dbpassword
PORT = 3306
CHARSET = 'utf8'
UNICODE = True
WARNINGS = True
@classmethod
def dbinfo(cls):
return {
'host': cls.HOST,
'port': cls.PORT,
'database': cls.DATABASE,
'user': cls.USER,
'password': cls.PASSWORD,
'charset': cls.CHARSET,
'use_unicode': cls.UNICODE,
'get_warnings': cls.WARNINGS,
}
最佳答案
根据官方文档中的MySQL Connector/Python :: 6 Connector/Python Connection Arguments:
要为连接设置超时值,请使用connection_timeout
。
关于python - 适用于Python的MySQL连接器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14167576/