Problem:
The function directly adds a new GuardItem without checking if a record with the same name (or ID) already exists.
When such a record exists, db.commit() raises an exception, causing a 500 Internal Server Error.
Expected Behavior:
Before creating a new GuardItem, the function should query the database to check for existing entries with the same unique fields.
