统计分析

This commit is contained in:
2026-09-23 09:46:15 +08:00
parent ca3cc80a0d
commit cfc3b423dc
7 changed files with 610 additions and 1 deletions
+15
View File
@@ -0,0 +1,15 @@
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()