mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 11:55:00 +00:00
checking for error in db input
This commit is contained in:
@@ -162,16 +162,21 @@ def image():
|
|||||||
def yolo_results_endpoint():
|
def yolo_results_endpoint():
|
||||||
global yolo_results
|
global yolo_results
|
||||||
with lock:
|
with lock:
|
||||||
db = get_db()
|
try:
|
||||||
with db.cursor() as cursor:
|
db = get_db()
|
||||||
sql_yolo = "INSERT INTO image (class, confidence) VALUES (%s, %s)"
|
with db.cursor() as cursor:
|
||||||
yolo_tuples = [(result["class"], result["confidence"]) for result in yolo_results]
|
sql_yolo = "INSERT INTO image (class, confidence) VALUES (%s, %s)"
|
||||||
print(f"YOLO Tuples: {yolo_tuples}") # Debug statement
|
yolo_tuples = [(result["class"], result["confidence"]) for result in yolo_results]
|
||||||
cursor.executemany(sql_yolo, yolo_tuples)
|
print(f"YOLO Tuples: {yolo_tuples}") # Debug statement
|
||||||
db.commit()
|
cursor.executemany(sql_yolo, yolo_tuples)
|
||||||
cursor.close()
|
db.commit()
|
||||||
|
cursor.close()
|
||||||
|
except mysql.connector.Error as err:
|
||||||
|
print(f"Database error: {err}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Unexpected error: {e}")
|
||||||
|
|
||||||
return jsonify(yolo_results)
|
return jsonify(yolo_results)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=True, port=5000)
|
app.run(debug=True, port=5000)
|
Reference in New Issue
Block a user