#!/usr/bin/env python3#-*- coding: utf-8 -*-import redis#Replace with the connected instance host and port herehost = '192.xx.xx.195'port = 6379#Replace with the instance ID and password hereuser='username'pwd='password'#When connecting, specify the AUTH information through the `password` parameter. If you connect through the default account, it is `pwd`. If you connect through a custom account, it is `user+'@'+pwd`r = redis.StrictRedis(host=host, port=port, password=user+'@'+pwd)#Database operations can be performed after the connection is established. For more information, visit https://github.com/andymccurdy/redis-pyr.set('name', 'python_test');print r.get('name')

import redis3 as redis3if __name__ == "__main__":#`vip` is the private IPv4 address for database connection, `6379` is the default port number, `pwd` is the password of the default account, and `ca.pem` is the obtained SSL certificate file. You need to replace them as needed.client = redis3.Redis(host="vip", port=6379, password="pwd", ssl=True, ssl_cert_reqs="required",ssl_ca_certs="ca.pem")print(client.ping())
Feedback