From 67b7871580e33e3dbbef5ca92aee9f4722f82060 Mon Sep 17 00:00:00 2001 From: Toan Quach Date: Mon, 13 Nov 2023 11:06:41 +0700 Subject: [PATCH] minor improvement --- src/taipy/core/_repository/_sql_repository.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/taipy/core/_repository/_sql_repository.py b/src/taipy/core/_repository/_sql_repository.py index 28b4820e..e0d8e79d 100644 --- a/src/taipy/core/_repository/_sql_repository.py +++ b/src/taipy/core/_repository/_sql_repository.py @@ -34,7 +34,7 @@ def __init__(self, model_type: Type[ModelType], converter: Type[Converter]): Attributes: model_type: Generic dataclass. converter: A class that handles conversion to and from a database backend - db: An SQLAlchemy session object + db: An sqlite3 session object """ self.db = _SQLConnection.init_db() self.model_type = model_type @@ -83,13 +83,11 @@ def _load_all(self, filters: Optional[List[Dict]] = None) -> List[Entity]: def _delete(self, entity_id: str): delete_query = self.table.delete().filter_by(id=entity_id) cursor = self.db.execute(str(delete_query.compile(dialect=sqlite.dialect())), [entity_id]) - self.db.commit() if cursor.rowcount == 0: raise ModelNotFound(str(self.model_type.__name__), entity_id) - if cursor.rowcount == 0: - raise ModelNotFound(str(self.model_type.__name__), entity_id) + self.db.commit() def _delete_all(self): self.db.execute(str(self.table.delete().compile(dialect=sqlite.dialect())))