统计分析
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user