Shymaa2611 commited on
Commit
0b88451
·
1 Parent(s): f7eea1b
Files changed (1) hide show
  1. db_utils.py +16 -14
db_utils.py CHANGED
@@ -50,23 +50,25 @@ def get_latest_prediction():
50
  return None
51
 
52
 
53
-
54
-
55
-
56
-
57
  def get_all_predictions():
58
  conn = sqlite3.connect(DB_FILE)
59
- cursor = conn.cursor()
60
- cursor.execute("SELECT * FROM predictions")
61
- rows = cursor.fetchall()
 
 
 
 
 
62
  conn.close()
 
63
  results = []
64
  for row in rows:
65
- if row:
66
- results.append({
67
- "input": json.loads(row[0]),
68
- "class": row[1],
69
- "probability": row[2],
70
- "timestamp": row[3]
71
- })
72
  return results
 
50
  return None
51
 
52
 
 
 
 
 
53
  def get_all_predictions():
54
  conn = sqlite3.connect(DB_FILE)
55
+ c = conn.cursor()
56
+ c.execute('''
57
+ SELECT input, predicted_class, probability, timestamp
58
+ FROM predictions
59
+ ORDER BY id DESC
60
+ LIMIT 2
61
+ ''')
62
+ rows = c.fetchall()
63
  conn.close()
64
+
65
  results = []
66
  for row in rows:
67
+ results.append({
68
+ "input": json.loads(row[0]),
69
+ "class": row[1],
70
+ "probability": row[2],
71
+ "timestamp": row[3]
72
+ })
73
+
74
  return results