db.py 文件源码

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

项目:fandango 作者: tango-controls 项目源码 文件源码
def getCursor(self,renew=True,klass=None):
        ''' 
        returns the Cursor for the database
        renew will force the creation of a new cursor object
        klass may be any of MySQLdb.cursors classes (e.g. DictCursor)
        MySQLdb.cursors.SSCursor allows to minimize mem usage in clients (although it relies memory cleanup to the server!)
        '''
        try:
            if klass in ({},dict):
                klass = MySQLdb.cursors.DictCursor
            if (renew or klass) and self._cursor: 
                if not self._recursion:
                    self._cursor.close()
                    del self._cursor
            if renew or klass or not self._cursor:
                self._cursor = self.db.cursor(self.default_cursor) if klass is None else self.db.cursor(cursorclass=klass)
            return self._cursor
        except:
            print traceback.format_exc()
            self.renewMySQLconnection()
            self._recursion += 1
            return self.getCursor(renew=True,klass=klass)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号