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

Function update_environment

misc/python/materialize/mzexplore/sql.py:128–140  ·  view source on GitHub ↗
(
    db: Database, env: dict[str, str]
)

Source from the content-addressed store, hash-verified

126
127@contextlib.contextmanager
128def update_environment(
129 db: Database, env: dict[str, str]
130) -> Generator[Database, None, None]:
131 original = dict()
132 for e in db.query_all("SHOW ALL"):
133 key, old_value = e["name"], e["setting"]
134 if key in env:
135 original[key] = old_value
136 new_value = env[key]
137 db.execute(f"SET {identifier(key)} = {literal(new_value)}")
138 yield db
139 for key, old_value in original.items():
140 db.execute(f"SET {identifier(key)} = {literal(old_value)}")
141
142
143# Utility functions

Callers

nothing calls this directly

Calls 4

identifierFunction · 0.85
query_allMethod · 0.45
executeMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected