diff options
author | Andy McCurdy <andy@andymccurdy.com> | 2020-08-15 16:16:28 -0700 |
---|---|---|
committer | Andy McCurdy <andy@andymccurdy.com> | 2020-08-15 16:16:28 -0700 |
commit | 6b37f4bedc349eb2c91e680d2ef811a3c2f7e879 (patch) | |
tree | fb998e8363449899bdb88fdacbb9f3a6d66807b9 /redis/client.py | |
parent | c73e07c883452d32ec273d04942e017814b04e54 (diff) | |
download | redis-py-6b37f4bedc349eb2c91e680d2ef811a3c2f7e879.tar.gz |
All values within Redis URLs are url-unquoted via default.
Prior versions of redis-py supported this by specifying the
``decode_components`` flag to the ``from_url`` functions. This is now done by
default and cannot be disabled.
Fixes #589
Diffstat (limited to 'redis/client.py')
-rwxr-xr-x | redis/client.py | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/redis/client.py b/redis/client.py index 881fd65..02db578 100755 --- a/redis/client.py +++ b/redis/client.py @@ -647,7 +647,7 @@ class Redis: } @classmethod - def from_url(cls, url, db=None, **kwargs): + def from_url(cls, url, **kwargs): """ Return a Redis client object configured from the given URL @@ -659,28 +659,35 @@ class Redis: Three URL schemes are supported: - - ```redis://`` - <http://www.iana.org/assignments/uri-schemes/prov/redis>`_ creates a - normal TCP socket connection - - ```rediss://`` - <http://www.iana.org/assignments/uri-schemes/prov/rediss>`_ creates a - SSL wrapped TCP socket connection - - ``unix://`` creates a Unix Domain Socket connection + - `redis://` creates a TCP socket connection. See more at: + <https://www.iana.org/assignments/uri-schemes/prov/redis> + - `rediss://` creates a SSL wrapped TCP socket connection. See more at: + <https://www.iana.org/assignments/uri-schemes/prov/rediss> + - ``unix://``: creates a Unix Domain Socket connection. - There are several ways to specify a database number. The parse function - will return the first specified option: + The username, password, hostname, path and all querystring values + are passed through urllib.parse.unquote in order to replace any + percent-encoded values with their corresponding characters. + + There are several ways to specify a database number. The first value + found will be used: 1. A ``db`` querystring option, e.g. redis://localhost?db=0 - 2. If using the redis:// scheme, the path argument of the url, e.g. - redis://localhost/0 - 3. The ``db`` argument to this function. + 2. If using the redis:// or rediss:// schemes, the path argument + of the url, e.g. redis://localhost/0 + 3. A ``db`` keyword argument to this function. + + If none of these options are specified, the default db=0 is used. - If none of these options are specified, db=0 is used. + All querystring options are cast to their appropriate Python types. + Boolean arguments can be specified with string values "True"/"False" + or "Yes"/"No". Values that cannot be properly cast cause a + ``ValueError`` to be raised. Once parsed, the querystring arguments + and keyword arguments are passed to the ``ConnectionPool``'s + class initializer. In the case of conflicting arguments, querystring + arguments always win. - Any additional querystring arguments and keyword arguments will be - passed along to the ConnectionPool class's initializer. In the case - of conflicting arguments, querystring arguments always win. """ - connection_pool = ConnectionPool.from_url(url, db=db, **kwargs) + connection_pool = ConnectionPool.from_url(url, **kwargs) return cls(connection_pool=connection_pool) def __init__(self, host='localhost', port=6379, |