sabo_database.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:sabo 作者: tokers 项目源码 文件源码
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.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号