from app.core.database import db_session tables = ['PerDocCatVal', 'tck', 'tckper', 'tckprx', 'tckhst', 'pdtmdl'] with db_session() as conn: c = conn.cursor(as_dict=True) for t in tables: print(f"--- {t} NOT NULL columns ---") c.execute(f""" SELECT COLUMN_NAME, DATA_TYPE, COLUMN_DEFAULT FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '{t}' AND IS_NULLABLE = 'NO' """) print("--- Sample PerDocCatVal ---") c.execute("SELECT TOP 3 * FROM PerDocCatVal") for r in c.fetchall(): print(r)