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

Method connect

misc/python/materialize/util.py:155–173  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

153 autocommit: bool = False
154
155 def connect(self) -> psycopg.Connection:
156 conn = psycopg.connect(
157 host=self.host,
158 port=self.port,
159 user=self.user,
160 password=self.password,
161 dbname=self.database,
162 sslmode="require" if self.ssl else None,
163 )
164 # Set SO_LINGER(1, 0) so close() sends RST instead of FIN, bypassing
165 # TIME_WAIT. Prevents exhausting the ~28k ephemeral port range under
166 # high connection churn (e.g. benchmarks doing rapid connect/disconnect).
167 self._set_linger(conn)
168 if self.autocommit:
169 conn.autocommit = True
170 if self.cluster:
171 with conn.cursor() as cur:
172 cur.execute(f"SET cluster = {self.cluster}".encode())
173 return conn
174
175 @staticmethod
176 def _set_linger(conn: psycopg.Connection) -> None:

Callers 15

run_onceFunction · 0.95
mainFunction · 0.45
mainFunction · 0.45
ingestFunction · 0.45
get_mysql_source_connFunction · 0.45
_copy_chunkFunction · 0.45
_mysql_chunkFunction · 0.45
__init__Method · 0.45
_connect_sqlFunction · 0.45
mainFunction · 0.45
sql_connectionMethod · 0.45

Calls 4

_set_lingerMethod · 0.95
cursorMethod · 0.80
executeMethod · 0.45
encodeMethod · 0.45

Tested by 2

connectFunction · 0.36
create_connectionMethod · 0.36