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

Method copy_other_schemas_from

mycli/sqlcompleter.py:1186–1209  ·  view source on GitHub ↗

Copy per-schema metadata from *source*, skipping *exclude*. After a completion refresh swaps in a fresh completer that was populated only with the current schema's data, this restores any previously-loaded metadata for other schemas so the user can keep using qualifi

(self, source: "SQLCompleter", exclude: str | None)

Source from the content-addressed store, hash-verified

1184 self._register_schema_completions(schema, table_columns, functions)
1185
1186 def copy_other_schemas_from(self, source: "SQLCompleter", exclude: str | None) -> None:
1187 """Copy per-schema metadata from *source*, skipping *exclude*.
1188
1189 After a completion refresh swaps in a fresh completer that was
1190 populated only with the current schema's data, this restores any
1191 previously-loaded metadata for other schemas so the user can keep
1192 using qualified completions (``OtherSchema.table``) without a
1193 re-fetch.
1194 """
1195 kinds = ("tables", "views", "functions", "procedures", "enum_values", "foreign_keys")
1196 for kind in kinds:
1197 src_map = source.dbmetadata.get(kind, {})
1198 dest_map = self.dbmetadata.setdefault(kind, {})
1199 for schema_name, data in src_map.items():
1200 if not schema_name or schema_name == exclude:
1201 continue
1202 if schema_name in dest_map:
1203 continue
1204 dest_map[schema_name] = data
1205 for schema_name, table_columns in self.dbmetadata["tables"].items():
1206 if schema_name == exclude:
1207 continue
1208 functions = self.dbmetadata.get("functions", {}).get(schema_name, {})
1209 self._register_schema_completions(schema_name, table_columns, functions)
1210
1211 def _register_schema_completions(
1212 self,

Calls 2

getMethod · 0.45