Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
minor improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Toan Quach authored and Toan Quach committed Nov 13, 2023
1 parent 79ca334 commit 67b7871
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/taipy/core/_repository/_sql_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())))
Expand Down

0 comments on commit 67b7871

Please sign in to comment.