Skip to content

Commit

Permalink
implement py-actor-manager(it seems it's impossible to use triple quo…
Browse files Browse the repository at this point in the history
…tes)
  • Loading branch information
Maksym-Turenko committed Aug 23, 2024
1 parent e300d98 commit 2aa6a69
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions app/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,34 @@ def __init__(self) -> None:

def create(self, first_name: str, last_name: str) -> None:
self._connection.execute(
f"""
INSERT INTO {self.table_name} (first_name, last_name)
VALUES (?, ?)
""",
f"INSERT INTO {self.table_name} (first_name, last_name) "
f"VALUES (?, ?)",
(first_name, last_name)
)
self._connection.commit()

def all(self) -> list[Actor]:
cinema_cursor = self._connection.execute(
f"""SELECT * FROM {self.table_name}"""
f"SELECT * "
f"FROM {self.table_name}"
)
actors = [Actor(*row) for row in cinema_cursor]
cinema_cursor.close()
return actors

def update(self, _id: int, new_name: str, new_last_name: str) -> None:
self._connection.execute(
f"""
UPDATE {self.table_name}
SET first_name = ?, last_name = ?
WHERE id = ?
""",
f"UPDATE {self.table_name} "
f"SET first_name = ?, last_name = ? "
f"WHERE id = ?",
(new_name, new_last_name, _id)
)
self._connection.commit()

def delete(self, _id: int) -> None:
self._connection.execute(
f"""
DELETE FROM {self.table_name}
WHERE id = ?
""",
f" DELETE FROM {self.table_name} "
f"WHERE id = ?",
(_id,)
)
self._connection.commit()
Expand Down

0 comments on commit 2aa6a69

Please sign in to comment.