You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The view_products(), view_sales(), view_customers(), view_admins() methods could be refactored by creating a new display_table() method which takes a table name and a list of column names as arguments
Sample code from chatGPT:
def display_table(self, table_name, columns):
"""Display data from the specified table"""
# Query the table and fetch the data
self.cursor.execute(f"SELECT * FROM {table_name}")
data = self.cursor.fetchall()
# Display the data in a tabular format
labels = "\t".join(columns)
print(labels)
for row in data:
values = "\t".join(str(x) for x in row)
print(values)
input("Press Enter to continue...\n")
def view_products(self):
"""Display all products in the database"""
# Define the columns to display
columns = ["Product ID", "Name", "Price", "Quantity in Stock"]
# Call the display_table function with the appropriate arguments
self.display_table("products", columns)
The text was updated successfully, but these errors were encountered:
The
view_products()
,view_sales()
,view_customers()
,view_admins()
methods could be refactored by creating a newdisplay_table()
method which takes a table name and a list of column names as argumentsSample code from chatGPT:
The text was updated successfully, but these errors were encountered: