Explorer
/tmp/yt_audit.py
← Zurück ↓ Download
import sqlite3, os, datetime
paths=['/opt/struktur/knowledge.db','/opt/struktur/youtube-research/knowledge.db']
for p in paths:
    print('\nDB',p)
    print('exists',os.path.exists(p),'size',os.path.getsize(p) if os.path.exists(p) else None,'mtime_utc',datetime.datetime.utcfromtimestamp(os.path.getmtime(p)).isoformat()+'Z' if os.path.exists(p) else None)
    if not os.path.exists(p): continue
    con=sqlite3.connect('file:'+p+'?mode=ro',uri=True)
    tabs=[r[0] for r in con.execute("select name from sqlite_master where type='table' order by name")]
    print('tables',tabs)
    for t in ['videos','source_processing_registry','graphiti_import_queue']:
        if t in tabs:
            print(t,'rows',con.execute(f'select count(*) from {t}').fetchone()[0])
            print(t,'columns',[r[1] for r in con.execute(f'pragma table_info({t})')])
    con.close()