Skip to content

Commit c45d253

Browse files
authored
Merge pull request #81 from Xento/main
fixed return values for printhistory
2 parents 0a48096 + 6226b2b commit c45d253

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

print_history.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,13 +244,14 @@ def get_prints_by_spool(spool_id: int):
244244
Retrieves all print jobs that used a specific spool.
245245
"""
246246
conn = sqlite3.connect(db_config["db_path"])
247+
conn.row_factory = sqlite3.Row
247248
cursor = conn.cursor()
248249
cursor.execute('''
249250
SELECT DISTINCT p.* FROM prints p
250251
JOIN filament_usage f ON p.id = f.print_id
251252
WHERE f.spool_id = ?
252253
''', (spool_id,))
253-
prints = cursor.fetchall()
254+
prints = [dict(row) for row in cursor.fetchall()]
254255
conn.close()
255256
return prints
256257

@@ -264,9 +265,9 @@ def get_filament_for_slot(print_id: int, ams_slot: int):
264265
WHERE print_id = ? AND ams_slot = ?
265266
''', (print_id, ams_slot))
266267

267-
results = cursor.fetchone()
268+
row = cursor.fetchone()
268269
conn.close()
269-
return results
270+
return dict(row) if row else None
270271

271272
def _ensure_layer_tracking_entry(print_id: int):
272273
conn = sqlite3.connect(db_config["db_path"])

0 commit comments

Comments
 (0)