Skip to content

Commit

Permalink
develope
Browse files Browse the repository at this point in the history
  • Loading branch information
flatchers committed Jul 18, 2023
1 parent d7b9106 commit cc0aa50
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions app/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,28 @@


class ActorManager:
def __init__(self):
def __init__(self) -> None:
self._connection = sqlite3.connect("D:/sqlitestudio/cinema.db3")

def create(self, first_name_, last_name_):
def create(self, first_name_: str, last_name_: str) -> None:
self._connection.execute(
"INSERT INTO actors (first_name, last_name) VALUES (?, ?)", (first_name_, last_name_,)
"INSERT INTO actors (first_name, last_name) VALUES (?, ?)",
(first_name_, last_name_,)
)
self._connection.commit()

def all(self):
def all(self) -> list:
actors_data = self._connection.execute(
"SELECT * FROM actors"
)
return [Actor(*row) for row in actors_data]

def update(self, id_, new_first_name, new_last_name):
def update(
self,
id_: int,
new_first_name: str,
new_last_name: str
) -> None:
self._connection.execute(
"UPDATE actors "
"SET first_name = ?, last_name =? "
Expand All @@ -28,13 +34,10 @@ def update(self, id_, new_first_name, new_last_name):
)
self._connection.commit()

def delete(self, id_):
def delete(self, id_: int) -> None:
self._connection.execute(
"DELETE FROM actors "
"WHERE id = ?",
(id_,)
)
self._connection.commit()



0 comments on commit cc0aa50

Please sign in to comment.