2023-10-24 22:49:22 +08:00
|
|
|
import sys, sqlite3, pickle
|
2023-11-17 13:21:11 +08:00
|
|
|
from tinygrad.helpers import CACHEDB
|
2023-10-23 01:56:57 +08:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-11-17 13:21:11 +08:00
|
|
|
fn = sys.argv[1] if len(sys.argv) > 1 else CACHEDB
|
2023-10-23 01:56:57 +08:00
|
|
|
conn = sqlite3.connect(fn)
|
|
|
|
cur = conn.cursor()
|
|
|
|
cur.execute("SELECT name FROM sqlite_master WHERE type='table'")
|
|
|
|
for f in cur.fetchall():
|
|
|
|
table = f[0]
|
|
|
|
cur2 = conn.cursor()
|
|
|
|
cur2.execute(f"SELECT COUNT(*) FROM {table}")
|
|
|
|
cnt = cur2.fetchone()[0]
|
|
|
|
print(f"{table:20s} : {cnt}")
|
2023-10-24 22:49:22 +08:00
|
|
|
|
|
|
|
cur3 = conn.cursor()
|
|
|
|
cur3.execute(f"SELECT * FROM {table} LIMIT 10")
|
|
|
|
for f in cur3.fetchall():
|
|
|
|
v = pickle.loads(f[-1])
|
2023-11-02 09:44:00 +08:00
|
|
|
print(" ", len(f[0]) if isinstance(f[0], str) else f[0], f[1:-1], str(v)[0:50])
|
2023-10-24 22:49:22 +08:00
|
|
|
#print(f"{len(k):10d}, {sk} -> {v}")
|