Feat: add gets and delete api paths for students
This commit is contained in:
@@ -77,12 +77,29 @@ class StudentSQLiteRepository(AbstractRepository):
|
||||
rows = cursor.fetchall()
|
||||
return [self._rebuild_student(r, tribes) for r in rows]
|
||||
|
||||
def delete(self, student: Student) -> None:
|
||||
def list_id(self):
|
||||
cursor = self.conn.cursor()
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT id FROM students
|
||||
"""
|
||||
)
|
||||
|
||||
rows = cursor.fetchall()
|
||||
return [r[0] for r in rows]
|
||||
|
||||
def delete(self, id: str) -> None:
|
||||
students_id = self.list_id()
|
||||
if id not in students_id:
|
||||
raise StudentRepositoryError(
|
||||
f"The student {id} doesn't exists. Can't delete it."
|
||||
)
|
||||
|
||||
self.conn.execute(
|
||||
"""
|
||||
DELETE FROM students WHERE id=:id
|
||||
""",
|
||||
{
|
||||
"id": student.id,
|
||||
"id": id,
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user