MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / generate_meta

Function generate_meta

test/perf/many_table_reflection.py:72–96  ·  view source on GitHub ↗
(schema_name, table_number, min_cols, max_cols, dialect_name)

Source from the content-addressed store, hash-verified

70
71
72def generate_meta(schema_name, table_number, min_cols, max_cols, dialect_name):
73 meta = sa.MetaData(schema=schema_name)
74 log = defaultdict(int)
75 for _ in range(table_number):
76 t = generate_table(meta, min_cols, max_cols, dialect_name)
77 log["tables"] += 1
78 log["columns"] += len(t.columns)
79 log["index"] += len(t.indexes)
80 log["check_con"] += len(
81 [c for c in t.constraints if isinstance(c, sa.CheckConstraint)]
82 )
83 log["foreign_keys_con"] += len(
84 [
85 c
86 for c in t.constraints
87 if isinstance(c, sa.ForeignKeyConstraint)
88 ]
89 )
90 log["unique_con"] += len(
91 [c for c in t.constraints if isinstance(c, sa.UniqueConstraint)]
92 )
93 log["identity"] += len([c for c in t.columns if c.identity])
94
95 print("Meta info", dict(log))
96 return meta
97
98
99def log(fn):

Callers 1

mainFunction · 0.85

Calls 1

generate_tableFunction · 0.85

Tested by

no test coverage detected