def update_customer_credit(name, credit_limit): try: Customer.update(poverty_score=credit_limit).where( Customer.name == name).execute() result = f'{name} now has a credit score of {credit_limit}' except DoesNotExist: result = f'{name} does not exist' return result
def update_customer_credit(customer_id, credit_limit): try: u = Customer.update(credit_limit=credit_limit).where( Customer.customer_id == customer_id) u.execute() except ValueError: print('Customer wasn\'t found.')
def update_customer_credit(customer_id, credit_limit): """ search an existing customer by customer_id and update their credit limit or raise a ValueError exception if the customer does not exist """ try: with database.transaction(): a_customer = Customer.get(Customer.customer_id == customer_id) logger.info(f'Customer: {customer_id} credit limit is ' f'{a_customer.credit_limit}.') except (IndexError, ValueError, peewee.DoesNotExist): logger.info(f'Customer: {customer_id} not found.') database.close() return with database.transaction(): query = (Customer.update({ Customer.credit_limit: credit_limit }).where(Customer.customer_id == customer_id)) query.execute() a_customer = Customer.get(Customer.customer_id == customer_id) logger.info(f'Customer: {customer_id} credit limit is updated to ' f'{a_customer.credit_limit}.') database.close()
def update_customer_credit(id, credit): try: Customer.get(Customer.customer_id == id) credit_update = Customer.update(credit_limit=credit).where(Customer.customer_id == id) x = credit_update.execute() except Exception as e: raise ValueError
def update_customer_credit(customer_id, limit): """Update the customer credit limit""" # db.connect() # db.execute_sql('PRAGMA foreign_keys = ON;') LOGGER.info(f"Updating the customer {customer_id} credit limt to {limit}") query = Customer.update(credit_limit=limit).where( Customer.customer_id == customer_id) query.execute()
def update_customer_credit(customer_id, credit_limit): try: u = Customer.update(credit_limit=credit_limit).where( Customer.customer_id == customer_id) u.execute() logging.info('Customer credit limit has been updated') except ValueError: logging.info('Customer wasn\'t found.')
def update_customer_credit(id, credit): logging.debug('Updating credit for customer %s', id) try: Customer.get(Customer.customer_id == id) credit_update = Customer.update(credit_limit=credit).where( Customer.customer_id == id) x = credit_update.execute() logging.info('Updated customer %s credit to %f', id, credit) except Exception as e: raise ValueError
def update_customer_credit(customer_id, credit_limit): """This function will search an existing customer by customer_id and \ update their credit limit or raise a ValueError exception if the customer \ does not exist.""" qry = (Customer.update({ Customer.credit_limit: credit_limit }).where(Customer.customer_id == customer_id)) try: qry.execute() except ValueError: logging.error('Customer id {} does not exist'.format(customer_id))
def update_customer_credit(cust_id, credit_limit): """ Query that updates a specific customer's credit limit. :param cust_id: :param new_credit_limit: :return: Updated credit limit """ update_query = Customer.update(credit_limit=credit_limit) \ .where(Customer.customer_id == cust_id) if not update_query.execute(): raise ValueError("Record does not exist") return True
def update_customer_credit(cust_id, new_credit_limit): """ Query that updates a specific customer's credit limit. :param cust_id: :param new_credit_limit: :return: Updated credit limit """ try: update_query = Customer.update(credit_limit=new_credit_limit) \ .where(Customer.customerid == cust_id) update_query.execute() except ValueError: print(f'Record record doe not exist')
def update_customer(**kwargs): update_customer = Customer.get_or_none( Customer.customer_id == kwargs['customer_id']) if update_customer: insert_dict = { kwarg: kwargs[kwarg] for kwarg in kwargs if kwarg != 'customer_id' } update_query = Customer.update(insert_dict).where( Customer.customer_id == kwargs['customer_id']) update_query.execute() else: raise ValueError
def update_customer_credit(customer_id, credit_limit): """ This function will update a customer's credit limit using the id field. """ db_customer = Customer.get(Customer.customer_id == customer_id) if db_customer is not None: logger.info('Customer %s found to update credit limit.', db_customer.customer_name) (Customer.update({ Customer.credit_limit: credit_limit }).where(Customer.customer_id == customer_id).execute()) else: logging.error('Customer ID: %s does not exist.', customer_id) raise ValueError()