Ejemplo n.º 1
0
def add_customer(
        customer_id,
        name,
        last_name,
        home_address,
        phone_number,
        email_address,
        status,
        credit_limit,
):
    """
    This function adds a new customer to the sqlite3 database.
    """
    logging.debug("Adding new customer, %s %s to database", name, last_name)
    try:
        Customers.create(
            customer_id=customer_id,
            name=name,
            last_name=last_name,
            home_address=home_address,
            phone_number=phone_number,
            email_address=email_address,
            status=status,
            credit_limit=credit_limit,
        )
    except Exception as e_val:
        logging.warning("Customer %s already exists", customer_id)
        logging.warning(e_val)
Ejemplo n.º 2
0
def add_customer(
        customer_id,
        name,
        last_name,
        home_address,
        phone_number,
        email_address,
        status,
        credit_limit,
):
    """
    This function adds a new customer to the sqlite3 database.
    """
    LOGGER.info("Adding new customer, %s %s to database", name, last_name)
    try:
        Customers.create(
            customer_id=customer_id,
            name=name,
            last_name=last_name,
            home_address=home_address,
            phone_number=phone_number,
            email_address=email_address,
            status=status,
            credit_limit=credit_limit,
        )
        LOGGER.info("Added new customer %s %s to database", name, last_name)
    except IntegrityError as e_val:
        LOGGER.warning("Customer %s already exists", customer_id)
        LOGGER.warning(e_val)