MCPcopy
hub / github.com/fluentpython/example-code-2e / gen_columns_sql

Function gen_columns_sql

24-class-metaprog/persistent/dblib.py:72–79  ·  view source on GitHub ↗
(fields: FieldMap)

Source from the content-addressed store, hash-verified

70
71
72def gen_columns_sql(fields: FieldMap) -> Iterator[ColumnSchema]:
73 for name, py_type in fields.items():
74 check_identifier(name)
75 try:
76 sql_type = SQL_TYPES[py_type]
77 except KeyError as e:
78 raise ValueError(f'type {py_type!r} is not supported') from e
79 yield ColumnSchema(name, sql_type)
80
81
82def make_schema_sql(table_name: str, fields: FieldMap) -> str:

Callers 3

test_gen_columns_sqlFunction · 0.90
make_schema_sqlFunction · 0.85
valid_tableFunction · 0.85

Calls 3

check_identifierFunction · 0.85
ColumnSchemaClass · 0.85
itemsMethod · 0.45

Tested by 1

test_gen_columns_sqlFunction · 0.72