feat(Inventory): update add method

This commit is contained in:
Kristofers Solo 2023-11-01 19:39:02 +02:00
parent a78734252c
commit f0087b97ce

View File

@ -29,8 +29,9 @@ class Inventory:
"""Close database connection."""
self.conn.close()
def add(self, book: Book) -> None:
def add(self, *books: list[Book]) -> None:
"""Add `Book` to the `Inventory`. `Book`s ISBN must be unique."""
for book in books:
try:
self.cursor.execute("INSERT INTO Book VALUES (?, ?, ?, ?, ?)", (book.isbn, book.title, book.author, book.price, book.stock))
self.conn.commit()