def add_customer(customer_id, first_name, last_name, home_address, phone_number, email_address, active_customer, credit_limit): """Add customer to customer_database""" try: connect_customer_db() with db.atomic(): new_customer = Customer.create(customer_id=customer_id, first_name=first_name, last_name=last_name, home_address=home_address, phone_number=phone_number, email_address=email_address, active_customer=active_customer, credit_limit=credit_limit) new_customer.save() logger.info(f"Added {customer_id} to the database.") except TypeError as err: logger.info(f"Could not add {customer_id} to the database.") logger.info(err) raise TypeError finally: db.close()
def add_customer(customer_id, first_name, last_name, mailing_address, phone_number, email_address, active_status, credit_limit): """Add a new customer to the database""" try: new_customer = Customer.create(customer_id=customer_id, first_name=first_name, last_name=last_name, mailing_address=mailing_address, phone_number=phone_number, email_address=email_address, active_status=active_status, credit_limit=credit_limit) new_customer.save() logging.info(f"Add new customer with id {customer_id} -OK") except TypeError as oops: logging.info(f"Add new customer with id of {customer_id} failed") logging.info(oops) raise oops