Пример #1
0
def delete_customer(_name):
    '''Delete a customer from the customer database.'''
    with db.transaction():
        to_delete = Customer.get_or_none(Customer.name == _name)
        if to_delete is not None:
            to_delete.delete_instance()
        if to_delete is None:
            LOGGER.warning('Customer %s does not exist', _name)
def delete_customer(_name):
    '''Delete a customer from the customer database.'''
    with db.transaction():
        result = Customer.get(Customer.name == _name)
        if result is not None:
            result.delete_instance()
            LOGGER.info("Deleted %s %s", result.name, result.last_name)
        if result is None:
            LOGGER.warning('Customer %s does not exist', _name)
Пример #3
0
def delete_customer(customer_id):
    '''delete customer_id info from database'''
    LOGGER.info(f'Deleting customer ID {customer_id} from Customer table')
    with db.transaction():
        try:
            del_cust = Customer.get(Customer.customer_id == customer_id)
            del_cust.delete_instance()
            del_cust.save()
        except Customer.DoesNotExist as error_message:
            LOGGER.error(
                f'Customer ID {customer_id} not found. {error_message}')
            raise ValueError
Пример #4
0
def add_customer(_name, _last_name, _home_address, _phone_number,
                 _email_address, _status, _poverty_score):
    '''add new customer function.'''
    try:
        with db.transaction():
            new_customer = Customer.create(name=_name,
                                           last_name=_last_name,
                                           home_address=_home_address,
                                           phone_number=_phone_number,
                                           email_address=_email_address,
                                           status=_status,
                                           poverty_score=_poverty_score)
            new_customer.save()
    except peewee.IntegrityError:
        LOGGER.warning("Customer Name %s is already taken.", _name)
Пример #5
0
def add_customer(customer_data):
    for guy in customer_data:
        try:
            with db.transaction():
                new_customer = Customer.create(
                    name=guy[0],
                    last_name=guy[1],
                    home_address=guy[2],
                    phone_number=guy[3],
                    email_address=guy[4],
                    status=guy[5],
                    poverty_score=guy[6]
                    )
                new_customer.save()
        except peewee.IntegrityError:
            print('IntegrityError, Error adding customer %s', guy)
def add_customer(customer_id, name, lastname, home_address, phone_number,
                 email_address, status, credit_limit):
    """
    This function will add a new customer to the sqlite3 database
    """
    try:
        with db.transaction():
            new_customer = Customer.create(customer_id=customer_id,
                                           customer_name=name,
                                           customer_lastname=lastname,
                                           customer_address=home_address,
                                           customer_phone_number=phone_number,
                                           customer_email=email_address,
                                           credit_limit=credit_limit,
                                           status=status)
            new_customer.save()
            logger.info('Customer %s successfully added.', name)

    except Exception as err:
        logger.info('Error creating %s', name)
        logger.info(err)