Python connection problems redis special character passwords

connection method:

self.pool = redis.ConnectionPool.from_url(self.redis_url)
opredis = redis.Redis(connection_pool=self.pool)
redis_url = 'redis://:cot$#D4^&[email protected]:6379/0'

Redis will complain directly connected, an error main elements:

ValueError: invalid literal for int() with base 10

Question: redis password does not allow special characters? # For details, please see ConnectionPool.from_url method

Solution:

Configuration password is the password to encode, decode password when connecting to

To python3 example:

from urllib import parse

redis_url = 'redis://:{}@172.31.26.174:6379/0'.format(parse.quote('cot$#D4^&1234'))

self.pool = redis.ConnectionPool.from_url(self.redis_url, , decode_components=True) 

opredis = redis.Redis(connection_pool=self.pool)

Guess you like

Origin www.cnblogs.com/liusijun113/p/11528686.html