import sqlite3 conn = sqlite3.connect('/root/cma-management/backend/cma.db') cursor = conn.cursor() tables = cursor.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name").fetchall() for t in tables: print(f'=== {t[0]} ===') cols = cursor.execute(f'PRAGMA table_info({t[0]})').fetchall() for c in cols: print(f' {c[1]:25s} {c[2]:15s} null={c[3]} default={c[4]} pk={c[5]}') rowcount = cursor.execute(f'SELECT COUNT(*) FROM {t[0]}').fetchone()[0] print(f' 行数: {rowcount}') print() conn.close()