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 []
评论列表
文章目录