MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / parse_pg_conn_string

Function parse_pg_conn_string

misc/python/materialize/util.py:199–212  ·  view source on GitHub ↗

Not supported natively by pg8000, so we have to parse ourselves

(conn_string: str)

Source from the content-addressed store, hash-verified

197
198
199def parse_pg_conn_string(conn_string: str) -> PgConnInfo:
200 """Not supported natively by pg8000, so we have to parse ourselves"""
201 url = urlparse(conn_string)
202 query_params = parse_qs(url.query)
203 assert url.username
204 assert url.hostname
205 return PgConnInfo(
206 user=unquote(url.username),
207 password=unquote(url.password) if url.password else url.password,
208 host=url.hostname,
209 port=url.port or 5432,
210 database=url.path.lstrip("/"),
211 ssl=query_params.get("sslmode", ["disable"])[-1] != "disable",
212 )
213
214
215FILTERED_ARGS = [

Callers 1

run_onceFunction · 0.90

Calls 3

PgConnInfoClass · 0.85
unquoteFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected