Exemplo n.º 1
0
    # order_items_lists = []
    # for date_range in date_ranges:
    # 	order_items_list = get_orders_by_date_range(date_range)

    # 	order_items_lists.append(order_items_list)

    order_items = []
    for x in order_items_lists:
        order_items.extend(x)

    print('Connecting to database...', end='')
    dc = DatabaseConnection()
    print('Done!')

    print('Inserting into tables...')

    print('	bi_vtex_order_items')
    dc.execute('TRUNCATE TABLE bi_vtex_order_items;')
    dc.insert_dict('bi_vtex_order_items', order_items, print_only=False)

    # skus_to_reduce = dc.select("""
    # 	SELECT
    # 		voi.vtex_sku as sku_id,
    # 		voi.quantity as ordered_quantity,
    # 		voi.status as status
    # 	from dbo.vtex_order_items voi
    # 	where status not in ('Faturado', 'Cancelado')
    # 	order by order_sequence
    # 	;
    # """, strip=True, dict_format=True)
Exemplo n.º 2
0
        product_checks = p.map(waterfall, products_to_check)

    # for x in products_to_check:
    # 	product_checks.append(f(x))

    products_to_search = []
    for product_check in product_checks:
        product_check['imagem_hd'] = False

        if not product_check['imagem_vtex']:
            products_to_search.append(product_check)

    found_products = search_directory(products_to_search)
    product_check_dict = make_dict(product_checks, None,
                                   ['produto', 'cor_produto'])
    try:
        for found_product in found_products:
            set_in_dict(product_check_dict, True, [
                found_product['produto'], found_product['cor_produto'],
                'imagem_hd'
            ])
    except Exception as e:
        pass

    dc.execute('TRUNCATE TABLE bi_vtex_product_waterfall;')
    dc.insert_dict(
        'bi_vtex_product_waterfall',
        list(for_each_leaf(product_check_dict, depth=2, return_keys=False)))

    end = time.time()
    print(end - start)