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

Function read_columns_sql

24-class-metaprog/persistent/dblib.py:98–102  ·  view source on GitHub ↗
(table_name: str)

Source from the content-addressed store, hash-verified

96
97
98def read_columns_sql(table_name: str) -> list[ColumnSchema]:
99 check_identifier(table_name)
100 con = get_connection()
101 rows = con.execute(f'PRAGMA table_info({table_name!r})')
102 return [ColumnSchema(r['name'], r['type']) for r in rows]
103
104
105def valid_table(table_name: str, fields: FieldMap) -> bool:

Callers 4

test_read_columns_sqlFunction · 0.90
valid_tableFunction · 0.85
ensure_tableFunction · 0.85

Calls 4

check_identifierFunction · 0.85
get_connectionFunction · 0.85
ColumnSchemaClass · 0.85
executeMethod · 0.80

Tested by 2

test_read_columns_sqlFunction · 0.72