Feat: add get_tribe for sqlite
This commit is contained in:
@@ -13,7 +13,19 @@ class TribeSQLiteRepository(AbstractRepository):
|
||||
pass
|
||||
|
||||
def get(self, name: str) -> Tribe:
|
||||
pass
|
||||
cursor = self.conn.cursor()
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT * FROM tribes WHERE name=?
|
||||
""",
|
||||
(name,),
|
||||
)
|
||||
|
||||
row = cursor.fetchone()
|
||||
if row:
|
||||
return Tribe(*row)
|
||||
|
||||
raise ValueError(f"The tribe {name} does not exists")
|
||||
|
||||
def list(self) -> list[Tribe]:
|
||||
cursor = self.conn.cursor()
|
||||
@@ -22,6 +34,7 @@ class TribeSQLiteRepository(AbstractRepository):
|
||||
SELECT * FROM tribes
|
||||
"""
|
||||
)
|
||||
|
||||
rows = cursor.fetchall()
|
||||
return [Tribe(*r) for r in rows]
|
||||
|
||||
|
Reference in New Issue
Block a user