20 lines
769 B
Python
20 lines
769 B
Python
import sys, glob, os, sqlite3
|
|
sys.stdout.reconfigure(encoding="utf-8")
|
|
|
|
files = sorted(glob.glob(r"\\tower\JNJEMAILS\db\jnjemails_*.db"))
|
|
db = files[-1]
|
|
print(f"DB: {os.path.basename(db)}\n")
|
|
|
|
conn = sqlite3.connect(db)
|
|
for (tbl,) in conn.execute("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"):
|
|
print(f"=== {tbl} ===")
|
|
for cid, name, ctype, notnull, dflt, pk in conn.execute(f"PRAGMA table_info({tbl})"):
|
|
flags = []
|
|
if pk: flags.append("PK")
|
|
if notnull: flags.append("NOT NULL")
|
|
if dflt is not None: flags.append(f"default={dflt}")
|
|
print(f" {name:14} {ctype:10} {' '.join(flags)}")
|
|
cnt = conn.execute(f"SELECT COUNT(*) FROM {tbl}").fetchone()[0]
|
|
print(f" → {cnt} řádků\n")
|
|
conn.close()
|