MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / ensure_table

Function ensure_table

24-class-metaprog/persistent/dblib.py:110–115  ·  view source on GitHub ↗
(table_name: str, fields: FieldMap)

Source from the content-addressed store, hash-verified

108
109
110def ensure_table(table_name: str, fields: FieldMap) -> None:
111 table_columns = read_columns_sql(table_name)
112 if len(table_columns) == 0:
113 create_table(table_name, fields)
114 if not valid_table(table_name, fields):
115 raise SchemaMismatch(table_name)
116
117
118def insert_record(table_name: str, data: dict[str, Any]) -> int:

Callers

nothing calls this directly

Calls 4

read_columns_sqlFunction · 0.85
create_tableFunction · 0.85
valid_tableFunction · 0.85
SchemaMismatchClass · 0.85

Tested by

no test coverage detected