def sabo_db_connect(db_conf):
ip = db_conf["db_addr"]
port = db_conf["db_port"]
user = db_conf["db_user"]
passwd = db_conf["db_passwd"]
db = db_conf["db_name"]
charset = "utf8"
for i in range(db_conf["db_retry"]):
try:
mysql_db = MySQLdb.connect(host=ip, port=port, user=user, passwd=passwd, db=db, charset=charset)
except Exception as e:
sabo_error_log("error", "Connect to mysql failed: {0}".format(e))
else:
return mysql_db
# if there are some tasks didn't be judged,
# then the process will be blocked until the queue is empty.
评论列表
文章目录