Spaces:
Sleeping
Sleeping
import sqlite3 | |
from datetime import datetime | |
conn = sqlite3.connect("db.sqlite", check_same_thread=False) | |
c = conn.cursor() | |
c.execute('''CREATE TABLE IF NOT EXISTS logs ( | |
timestamp TEXT, label TEXT, confidence REAL, alert INTEGER | |
)''') | |
conn.commit() | |
def log_result(result): | |
c.execute("INSERT INTO logs VALUES (?, ?, ?, ?)", ( | |
datetime.now().isoformat(), | |
result["prediction"], | |
result["confidence"], | |
int(result["alert"]) | |
)) | |
conn.commit() | |