mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 20:04:58 +00:00
checking for error in db input
This commit is contained in:
@@ -162,6 +162,7 @@ def image():
|
|||||||
def yolo_results_endpoint():
|
def yolo_results_endpoint():
|
||||||
global yolo_results
|
global yolo_results
|
||||||
with lock:
|
with lock:
|
||||||
|
try:
|
||||||
db = get_db()
|
db = get_db()
|
||||||
with db.cursor() as cursor:
|
with db.cursor() as cursor:
|
||||||
sql_yolo = "INSERT INTO image (class, confidence) VALUES (%s, %s)"
|
sql_yolo = "INSERT INTO image (class, confidence) VALUES (%s, %s)"
|
||||||
@@ -170,8 +171,12 @@ def yolo_results_endpoint():
|
|||||||
cursor.executemany(sql_yolo, yolo_tuples)
|
cursor.executemany(sql_yolo, yolo_tuples)
|
||||||
db.commit()
|
db.commit()
|
||||||
cursor.close()
|
cursor.close()
|
||||||
return jsonify(yolo_results)
|
except mysql.connector.Error as err:
|
||||||
|
print(f"Database error: {err}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Unexpected error: {e}")
|
||||||
|
|
||||||
|
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