예제 #1
0
def get_products_from_app_vip():
    sql = '''SELECT category_name,subcategory_name,brand_name,vendor_name,vendor_code,
             supc,Product_name, vendor_sku,pog, selling_price,vendor_price
             FROM analytics.lg_app_vip limit {} offset {};'''

    USDINR = get_usd_value()
    print '$1 = Rs. {}'.format(USDINR)
    print "populating orders"
    cnx = get_mysql_connection()
    cursor = cnx.cursor()

    count = 0
    offset = 0
    limit = 100
    while True:
        sql_limit = sql.format(limit, offset)
        count += 1
        offset = limit * count

        cursor.execute(sql_limit)
        rows = cursor.fetchall()
        if rows:
            for row in rows:
                create_or_update_ex_products.apply_async(args=[row, USDINR], queue='creator')
        else:
            break
예제 #2
0
def populate_ex_product_from_ex_vip():
    USDINR = get_usd_value()
    print '$1 = Rs. {}'.format(USDINR)
    print "populating orders"
    cnx = get_mysql_connection()
    cursor = cnx.cursor()

    sql = '''SELECT product_id,sku,pog,category,subcategory,brand_name,product_name,
                    global_vendor_price,global_selling_price,india_vendor_price,india_selling_price,
                    vendor_code,vendor_name
             FROM analytics.exclusively_vip
             where subcategory is not null and brand_id is not null and product_status = 'live' and
                   vendor_code != '' and vendor_name is not null;'''

    cursor.execute(sql)
    rows = cursor.fetchall()
    cnx.close()
    cnx.disconnect()

    for row in rows:
        create_or_update_ex_products.apply_async(args=[row, USDINR], queue='creator')