Question: Create a class def called 'product'. It should have the following methods: def setTable(self, table): #sets the table name if the table does not exist
Create a class def called 'product'. It should have the following methods:
def setTable(self, table): #sets the table name if the table does not exist in the DB, print an error otherwise
def setFields(self,fieldnames): #sets a class attribute with a list of strings which are fieldnames. Fieldnames should only contain lower case chars and underscores.
def createTable(self): # creates a table in the SQL database. You can assume all fields are varchar(255)
def removeTable(self): #delete (DROP) the created product table
Your submission should define the class and then run+pass the following unit tests:
p = product()
p.setTable('test_product') p.setFields(['id','name','sku','price','category'])
p.createTable()
p.removeTable()
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
