diff --git a/README.md b/README.md index effa8abe2d0378f1a36062b5c795692d5cb787c3..4508272d50c57ab0e24244c347bdc79f7b4b9d26 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,8 @@ # multi IP support, will return PRIMARY instance connect: >>> db = py_opengauss.open('opengauss://user:password@host1:123,host2:456/database') -# Connect to 'postgres' at localhost. +# Connect to 'postgres' at localhost with default user and password in the env, which only support postgresql. +# 注意: 该连接方式只支持PG, 不支持openGauss, 对于openGauss, 必须要输入user和password >>> db = py_opengauss.open('localhost/postgres') ``` diff --git a/py_opengauss/resolved/riparse.py b/py_opengauss/resolved/riparse.py index 523989a10c34996005699a57308e47df9dd60ef9..ee8b63cfcae6e8c5546e92f90f8a5a0dc7814e84 100644 --- a/py_opengauss/resolved/riparse.py +++ b/py_opengauss/resolved/riparse.py @@ -133,21 +133,25 @@ def split(s): end_of_netloc = end - path_pos = s.find('/', pos) - if path_pos == -1: + split_loc = s.rfind('@') + if split_loc == -1: + return scheme, netloc, path, query, fragment + + path_pos = s.rfind('/', pos) + if path_pos == -1 or path_pos < split_loc: path_pos = None else: end_of_netloc = path_pos - query_pos = s.find('?', pos) - if query_pos == -1: + query_pos = s.rfind('?', pos) + if query_pos == -1 or query_pos < split_loc: query_pos = None elif path_pos is None or query_pos < path_pos: path_pos = None end_of_netloc = query_pos - fragment_pos = s.find('#', pos) - if fragment_pos == -1: + fragment_pos = s.rfind('#', pos) + if fragment_pos == -1 or fragment_pos < split_loc: fragment_pos = None else: if query_pos is not None and fragment_pos < query_pos: @@ -244,7 +248,7 @@ def split_netloc(netloc, fieldproc = unescape): Set `fieldproc` to `str` if the components' percent escapes should not be decoded. """ - pos = netloc.find('@') + pos = netloc.rfind('@') if pos == -1: # No user information pos = 0