mysql.py 文件源码

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

项目:rental 作者: meihuanyu 项目源码 文件源码
def select_proxy(self, table_name, **kwargs):
        filter = {}
        for k, v in kwargs.items():
            if v != '':
                filter[k] = v

        try:
            command = "SELECT * FROM {name} WHERE anonymity LIKE '{anonymity}' AND https LIKE '{https}' ORDER BY " \
                      "{order} {sort} limit {count}". \
                format(name=table_name, anonymity=filter.get('anonymity', '%'),
                       https=filter.get('https', '%'), order=filter.get('order', 'save_time'),
                       sort=filter.get('sort', 'desc'), count=filter.get('count', 100))

            result = self.query(command)
            data = [{
                'ip': item[1], 'port': item[2], 'anonymity': item[4], 'https': item[5],
                'speed': item[6], 'save_time': str(item[8])
            } for item in result]
            return data
        except Exception as e:
            logging.exception('mysql select_proxy exception msg:%s' % e)
        return []
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号