import dataset import pymysql pymysql.install_as_MySQLdb() import redis import json db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4') table=db['selected_kw'] lst = [] cur = db.query('select term,url from seo.sns_kw where client="loginheart"') for c in cur: lst.append([c['term'],c['url']]) print(lst) # r = redis.Redis(host='db.ptt.cx', port=6379, db=1,password='choozmo9') # r.set(lst) ['真皮迷你包', 'https://www.zeczec.com/projects/loginheart'], ['小廢包 品牌', 'https://www.zeczec.com/projects/loginheart'], ['電子支付包包', 'https://www.zeczec.com/projects/loginheart'], ['感應支付 小包包', 'https://www.zeczec.com/projects/loginheart'], ['一卡通小包', 'https://www.zeczec.com/projects/loginheart'], ['迷你包 推薦', 'https://www.zeczec.com/projects/loginheart'], ['科技 小廢包', 'https://www.zeczec.com/projects/loginheart'], ['小配方包', 'https://www.zeczec.com/projects/loginheart'], ['精品包包', 'https://www.zeczec.com/projects/loginheart'], ['時尚科技 台灣 包包品牌', 'https://www.zeczec.com/projects/loginheart']