qq-22432832

Python批量新增/更新Pika库 On Linux

  • pika安装 (点我进官网)

  • 要插入的数据

任务ID平台value1value2value3
taskaandroid123
taskbios234
taskcother345
# coding=UTF-8
import subprocess

ssh_command = r"redis-cli -h xx.xxx.xxx.xxx -p xxxxx -a 'xxxxxx'"
input_file = r'/home/xxxxxx/zhangjinke/tasks.txt'
with open(input_file,'r') as file:
    file_list = file.readlines()
    for i in file_list:
        data = i.strip().split('\t')
        taskid = data[0]
        channel = data[1]
        send_pv = data[2]
        show_uv = data[3]
        open_uv = data[4]
        command = r'hmset taskid:' + taskid + '@@' + channel + ' send_pv ' + send_pv + ' show_uv ' + show_uv + ' open_uv ' + open_uv
        # print(command)
        a = subprocess.call(ssh_command+' '+command,shell=True)

        if a==0:
            continue
        else:
            print('更新失败:' + i)

posted on   春马与夏  阅读(8)  评论(0编辑  收藏  举报  

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示