MCPcopy Create free account
hub / github.com/dbcli/mycli / split_dsn_netloc

Function split_dsn_netloc

mycli/cli_runner.py:45–67  ·  view source on GitHub ↗
(netloc: str)

Source from the content-addressed store, hash-verified

43
44
45def split_dsn_netloc(netloc: str) -> tuple[str | None, str | None, str | None, str | None]:
46 username = None
47 password = None
48 host_port = netloc
49
50 if '@' in host_port:
51 user_info, host_port = host_port.rsplit('@', 1)
52 username, separator, password = user_info.partition(':')
53 if not separator:
54 password = None
55
56 if not host_port:
57 return username, password, None, None
58
59 if host_port.startswith('['):
60 end = host_port.find(']')
61 if end >= 0:
62 host = host_port[1:end]
63 port = host_port[end + 2 :] if host_port[end + 1 : end + 2] == ':' else None
64 return username, password, host, port
65
66 host, separator, port = host_port.partition(':')
67 return username, password, host or None, port if separator else None
68
69
70def expand_dsn_alias_env_vars(

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected