Adding model deletion feature from database
This commit is contained in:
@@ -201,6 +201,28 @@ class DatabaseManager:
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
def delete_model(self, model_id: int) -> bool:
|
||||
"""Delete a model from the database.
|
||||
|
||||
Note: detections referencing this model are deleted automatically via
|
||||
the `detections.model_id` foreign key (ON DELETE CASCADE).
|
||||
|
||||
Args:
|
||||
model_id: ID of the model to delete.
|
||||
|
||||
Returns:
|
||||
True if a model row was deleted, False otherwise.
|
||||
"""
|
||||
|
||||
conn = self.get_connection()
|
||||
try:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("DELETE FROM models WHERE id = ?", (model_id,))
|
||||
conn.commit()
|
||||
return cursor.rowcount > 0
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
# ==================== Image Operations ====================
|
||||
|
||||
def add_image(
|
||||
|
||||
Reference in New Issue
Block a user