Files
USB-AIO/scripts/db-view.py
Denis Stoecklmeier 81f06cf6b4
Some checks failed
Tests / test (push) Has been cancelled
USB-AIO für automatische Geräteprüfung
2026-10-14 20:14:36 +02:00

11 lines
639 B
Python

#!/usr/bin/env python3
import pathlib, sqlite3, sys
p=pathlib.Path(sys.argv[1])
if not p.is_file():
print('No database scans yet.'); sys.exit(0)
with sqlite3.connect(f'file:{p}?mode=ro', uri=True) as db:
print('Total scans:', db.execute('SELECT count(*) FROM scans').fetchone()[0])
print('Unique assets:', db.execute('SELECT count(DISTINCT asset_id) FROM scans').fetchone()[0])
for asset, model, gate, timestamp in db.execute('SELECT asset_id, model, health_gate, scanned_at_unix FROM scans ORDER BY scan_id DESC LIMIT 15'):
print(f'{asset:14} | {(model or "unknown")[:28]:28} | {gate or "UNKNOWN"} | {timestamp}')