from database import engine from sqlalchemy import text conn = engine.connect() tables = conn.execute(text("SHOW TABLES")).fetchall() print('Tables:', tables) for t in tables: tname = t[0] rows = conn.execute(text(f"SHOW COLUMNS FROM `{tname}` WHERE Field = 'is_deleted'")).fetchall() if rows: vals = conn.execute(text(f"SELECT is_deleted, COUNT(*) FROM `{tname}` GROUP BY is_deleted")).fetchall() print(f" {tname}: type={rows[0][1]}, values={vals}") conn.close()