Example #1
0
def save_data():
    """
    获取用户联系信息和报警信息管道写入redis
    :return:
    """

    alert_data = get_alert_info()

    user_data = get_user_info()
    userdata = [json.loads(x) for x in user_data]

    with redis_conn.pipeline(transaction=False) as p:
        for alert in alert_data:
            for u in userdata:
                if alert.get('nicknames'):
                    if u.get('nickname') in alert.get('nicknames').split(','):
                        #print(alert.get('keyword'), {u.get('tel'): u.get('email')})
                        save_data = {u.get('tel'): u.get('email')}
                        p.hmset(alert.get('keyword'), save_data)
        p.execute()
Example #2
0
def save_data():
    """
    提醒内容写入redis
    :return:
    """

    # 付费信息
    paid_data = get_paid_info()
    # CODO用户信息
    user_data = get_user_info()
    userdata = [json.loads(x) for x in user_data]
    with redis_conn.pipeline(transaction=False) as p:
        for remind in paid_data:
            # print(remind)
            for u in userdata:
                if remind.get('nicknames'):
                    if u.get('nickname') in remind.get('nicknames').split(','):
                        #print(remind.get('paid_name'), {u.get('tel'): u.get('email')})
                        save_data = {u.get('tel'): u.get('email')}
                        p.hmset(remind.get('paid_name'), save_data)
        p.execute()