RedisPython连接腾讯云数据库Redis

Python连接

  • step1:下载redispython客户端

gitclonehttps://github.com/andymccurdy/redis-py

  • step2:编写测试用例

#!/usr/bin/envpython#--coding:utf-8--importredis#这里替换为连接的腾讯云数据库host和porthost='jredis-cn-north-1-prod-redis-xxxxxxxxxx.jdcloud.com'port=6379#这里配置passwordpassword=''#连接时通过password参数指定AUTH信息r=redis.StrictRedis(host=host,port=port,password=password)#连接建立后就可以进行数据库操作,详情文档参考https://github.com/andymccurdy/redis-pyr.set('foo','bar');printr.get('foo')