db.py 文件源码

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

项目:postsai 作者: postsai 项目源码 文件源码
def connect(self):
        """connects to the database"""

        self.conn = mdb.connect(
            host    = self.config["db"]["host"],
            user    = self.config["db"]["user"],
            passwd  = self.config["db"]["password"],
            db      = self.config["db"]["database"],
            port    = self.config["db"].get("port", 3306),
            use_unicode = True,
            charset = "utf8")

        # checks whether this is a ViewVC database instead of a Bonsai database
        cursor = self.conn.cursor()
        cursor.execute("show tables like 'commits'")
        self.is_viewvc_database = (cursor.rowcount == 1)
        cursor.execute("SET SESSION innodb_lock_wait_timeout = 500")
        cursor.close()
        self.conn.begin()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号