Fixed all pep8 warnings

This commit is contained in:
2024-01-21 22:22:29 +00:00
parent 44c1ee03ba
commit bca3b0a663
14 changed files with 64 additions and 43 deletions

View File

@@ -22,7 +22,11 @@ class ProductController(DatabaseController):
]
self._conn.execute(
"INSERT INTO Products (name, image, description, cost, categoryID, sellerID, postedDate, quantityAvailable) VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
"""
INSERT INTO Products
(name, image, description, cost, categoryID,
sellerID, postedDate, quantityAvailable)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)""",
params
)
self._conn.commit()
@@ -38,7 +42,7 @@ class ProductController(DatabaseController):
)
rows = cursor.fetchmany()
if rows == None:
if rows is None:
return None
products = list()
@@ -51,16 +55,17 @@ class ProductController(DatabaseController):
return products
def read_all(self, category: str = "", search_term: str = "") -> list[Product] | None:
def read_all(self, category: str = "",
search_term: str = "") -> list[Product] | None:
params = [
"%" + category + "%",
"%" + search_term + "%"
]
cursor = self._conn.execute(
"""SELECT * FROM Products
INNER JOIN Categories ON Products.categoryID = Categories.id
WHERE Categories.name LIKE ?
"""SELECT * FROM Products
INNER JOIN Categories ON Products.categoryID = Categories.id
WHERE Categories.name LIKE ?
AND Products.name LIKE ?
""",
params