def convertPhoneToDBData(phone: PhoneData): return { 'BRAND': phone.getBrand(), 'MODEL': phone.getDBModel(), 'NAME': phone.getName(), 'TYPE': 'Mobile', 'PRICE': phone.getPrice(), 'VENDOR': phone.getVendor(), 'INFO': phone.getInfo() }
def deleteItemFromDB(self, item: PhoneData): try: _ = self.table.delete_item(Key={ 'BRAND': item.getBrand(), 'MODEL': item.getDBModel() }, ) except ClientError as e: print(e.response['Error']['Message']) else: pass
def updateItemToDB(self, item: PhoneData): try: _ = self.table.update_item( Key={ 'BRAND': item.getBrand(), 'MODEL': item.getDBModel() }, UpdateExpression="set INFO = :i, PRICE = :p", ExpressionAttributeValues={ ':p': item.getPrice(), ':i': item.getInfo() }, ReturnValues="UPDATED_NEW") except ClientError as e: print(e.response['Error']['Message']) else: pass